【发布时间】:2018-04-27 10:41:37
【问题描述】:
我是春天世界的新手, 所以我研究了一个 HelloWorld 示例,我编写了以下简单的控制器:
Controller
@RequestMapping("/welcome")
public class HelloWorldController{
@RequestMapping(method = RequestMethod.GET)
public ModelAndView helloWorld(){
ModelAndView model = new ModelAndView("MVC_First_Page");
model.addObject("msg", "hello world");
return model;
}
我收到以下错误:
Error resolving template "error", template might not exist or might not be accessible by any of the configured Template Resolvers
Caused by: org.thymeleaf.exceptions.TemplateInputException:
解析模板“错误”时出错,模板可能不存在或可能无法被任何已配置的模板解析器访问
为什么拦截器看不到 MVC_First_Page.jsp 页面?我已将其扩展名更改为 .html 并且可以正常工作。
我应该将此属性添加到 application.properties 文件吗?
spring.mvc.view.prefix:
spring.mvc.view.suffix: .jsp
【问题讨论】:
-
需要设置前缀和后缀。 logicbig.com/tutorials/spring-framework/spring-boot/… 我不会将 JSP 文件保存在静态文件夹中,因为这些显然不是静态资源。