springboot中添加前后缀问题:
一、springboot中访问html页面有两种默认的模板:thymeleaf(推荐)和freemarker
二、springboot中也可以访问jsp页面(不推荐)
1、thymeleaf模板
准备:导入spring-boot-starter-freemarker坐标
①.properties
#html路径解析
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
#不启用缓存
spring.thymeleaf.cache=false
②.yml/.yaml
spring:
thymeleaf:
prefix: classpath:/templates/
suffix: .html
#不启用缓存
cache: false
2、freemarker模板
准备:导入spring-boot-starter-freemarker坐标
①.properties
#html路径解析
spring.freemarker.suffix=.html
spring.freemarker.template-loader-path=classpath:/templates/
#不启用缓存
spring.freemarker.cache=false
②.yml/.yaml
spring:
freemarker:
template-loader-path: classpath:/templates/
suffix: .html
#不启用缓存
cache: false
3、访问jsp页面
准备:导入tomcat-embed-jasper坐标
①.properties
#jsp路径解析
spring.mvc.view.prefix=/WEB-INF/
spring.mvc.view.suffix=.jsp
②.yml/.yaml
spring:
mvc:
view:
prefix: /WEB-INF/
suffix: .jsp