IDEA springboot的 Cannot resolve MVC View 'index' 怎么解决?

图片说明
用的是spring thymeleaf
这种方法来做的 图片说明

欢迎你!
欢迎来到Thymeleaf的世界

这句话没有出来。。。。

参数index前面加上/试试,如

modelAndView = new ModelAndView(“/index”);

检查你的pom文件,有没有加依赖

我也是看别人这样说的

导错包了,试试

import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

添加依赖

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