代码之家  ›  专栏  ›  技术社区  ›  Theo

Thymeleaf在Spring Boot 2.0.6中无法识别

  •  0
  • Theo  · 技术社区  · 7 年前

    我在pom.xml中遇到了一个奇怪的错误

    pom.xml

    我不明白为什么我不能读取localhost:8080url。很奇怪。

    这是我的控制器

    @Controller
    public class IndexController {
    
    @RequestMapping({"","/","index"})
       public String getIndexPage(){
        return "index";
       }
    }
    

    和我的index.html

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Recipes Page</title>
    <h1>Recipes Index Page</h1>
    </head>
    <body>
    
    </body>
    </html>
    

    为什么会这样?

    1 回复  |  直到 7 年前
        1
  •  0
  •   nijogeorgep    7 年前

    在POM.xml中添加以下依赖项

            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
    

    请查看以下应用程序:

    https://spring.io/guides/gs/serving-web-content/