简直愚蠢的错误:搞了我快一个小时,记录以自勉。
- 刚开始是出现了:Could not resolve view with name ‘index’ in servlet with name ‘dispatcherServlet’
有文章说是因为没有配置好静态资源的路径,但是我在application.properties中已经配置了html对应的路径:
#thymeleaf start
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
#spring.thymeleaf.content-type=text/html
#开发时关闭缓存,不然没法看到实时页面
spring.thymeleaf.cache=false
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
#thymeleaf end
但是我还是尝试了网上所说的方式:启动类继承自WebConfigurationSurport,加上@EnableWebMvc注解:
详见:https://blog.csdn.net/testcs_dn/article/details/80249894
/**
* 配置JSP视图解析器
* 如果没有配置视图解析器。Spring会使用BeanNameViewResolver,通过查找ID与逻辑视图名称匹配且实现了View接口的beans
*
* @return
*/
@Bean
public InternalResourceViewResolver setupV