SpringBoot跳轉Html404問題


1.在pom.xml中添加thymeleaf依賴:

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

 

 

2.在application.properties(或者.yaml)中添加配置:

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html

classpath:/后跟的是resources下的路徑

注意: 這里不要寫 spring.mvc.view.prefix 和 spring.mvc.view.suffix 因為我們引入了thymeleaf所以要用thymeleaf的.

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM