1、Thymeleaf模板
引入yhemeleaf
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
①.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模板
引入freemarker
<!-- 引入freeMarker的依赖包. -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
①.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