Spring Boot 访问templates下的html文件出现404或者500的错误

1.项目配置

application.properties

1 #thymelea模板配置
2 spring.thymeleaf.suffix=.html
3 spring.thymeleaf.mode=HTML5
4 spring.thymeleaf.encoding=UTF-8
5 spring.thymeleaf.servlet.content-type=text/html
View Code

pom.xml

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

 PageController.java

@Controller
public class PageController{ 
@RequestMapping("/index") 
public String index(){ return "indexs"; 
} 
}

  

2.项目结构

 

然后如果出现404或者505的话

有可能是maven引入的包有问题导致的

IDEA解决方案

右键项目 -》 找到Maven -》 选择Reimport即可,然后重启

eclipse构建的时候让maven重新下载所需jar包才可以。

 

posted @ 2018-12-22 17:26  Angry-rookie  阅读(6223)  评论(0)    收藏  举报