Spring Boot Controller返回语句创建循环视图路径

public class FrontendController {

    public String hello(){

        return "hello";

going tohttp://localhost:8080/front/hello gives whitelabel error and

Circular view path [hello]: would dispatch back to the current handler URL [/front/hello] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)

如果我将返回值从“ hello”更改为其他任何值,那么我会收到带有其他消息的白色标签

No message available


im trying to return the hello.html page to browser enter image description here

  • cut
    cut 回复



    1. You want to use hello.html as the view
    2. You want to use Thymeleaf as your view provider

    To achieve that, you need a registered ViewResolver that uses Thymeleaf. If you include spring-boot-starter-thymeleaf on the classpath, one will be automatically registered for you.

    Then, move hello.html from static to templates and it should work.