springboot使用thymeleaf访问页面


springboot项目访问html页面和静态资源(如jquery、bootstrap等资源)时会访问不到,需要设置如下配置(每个人情况或者项目结构可能不一样,按照自己的需求来配置)

spring:
thymeleaf:
#配置html默认访问路径
prefix: classpath:/templates/
#配置后缀名
suffix: .html
mode: HTML5
encoding: UTF-8
#不使用缓存,开发过程中防止因缓存问题引起的资源访问问题
cache: false
servlet:
content-type: text/html
#配置静态资源的默认访问路径,不然访问不到static目录下的静态资源
mvc:
static-path-pattern: /static/**