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