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包才可以。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM