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