前言:
- 可以参考项目结构
- 在application.properties中配置h5页面的路径
一、直接上项目结构与代码框架:
二、application.properties的配置
#thymelea模板配置
#在构建URL时添加到视图名称前的前缀(默认值:classpath:/templates/)
spring.freemarker.template-loader-path=classpath:/templates/
#在构建URL时添加到视图名称后的后缀(默认值:.html)
spring.freemarker.suffix=.html
#要运用于模板之上的模板模式。另见StandardTemplate-ModeHandlers(默认值:HTML5)
spring.thymeleaf.mode=HTML5
#模板编码
spring.thymeleaf.encoding=UTF-8
##开启模板缓存(默认值:true)
spring.thymeleaf.cache=false
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**
#容器启动时加载优先级。当值小于0或者没有指定时,则表示容器在该servlet被选择时才会去加载;正数的值越小,该servlet的优先级越高,应用启动时就越先加载。
spring.mvc.servlet.load-on-startup=10
三、pom.xml配置
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.0.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->