Circular view path///Can't resolve view with name "" in servlet with name dispatcherServlet

在Springboot项目中遇到'Could not resolve view with name 'index' in servlet with name 'dispatcherServlet''的问题,尝试了配置静态资源路径、启用@EnableWebMvc、修改@RequestMapping路径等方法均未解决。最终发现是缺少Thymeleaf的依赖导致,添加Thymeleaf依赖后问题解决。同时提醒注意@RestController和@Controller注解的区别。
摘要由CSDN通过智能技术生成

简直愚蠢的错误:搞了我快一个小时,记录以自勉。

  1. 刚开始是出现了: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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值