【发布时间】:2014-06-12 00:45:07
【问题描述】:
我在配置 Spring Boot 以使用 thymeleaf 并仍然提供静态内容时遇到了麻烦。我的资源目录中有两个目录:“/static”和“/templates”。根据 Spring Boot 文档,thymeleaf 默认应该在模板目录中找到 thymeleaf 模板。但是,当我尝试使用模板时,我得到了 404。
来自我的控制器的相关代码:
@RequestMapping("/")
public ModelAndView index() {
return new ModelAndView("index.html");
}
@RequestMapping(value = "/test")
public ModelAndView test() {
return new ModelAndView("test");
}
index.html 位于 resources/static 中,而 test.html 位于 resources/templates 中。
index.html 可以正常工作,但是如果您尝试在浏览器中打开 /test,它会抛出 404 提示找不到 thymeleaf 模板。
我非常感谢任何帮助。我被难住了。
【问题讨论】:
-
请同时发布您的 thymeleaf 配置。
-
能否请您发布您的 Spring Boot 配置?
标签: spring thymeleaf spring-boot