博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
thymeleaf注入springboot
阅读量:7223 次
发布时间:2019-06-29

本文共 1371 字,大约阅读时间需要 4 分钟。

thymeleaf注入springboot需要引入jar:

org.springframework.boot
spring-boot-starter-thymeleaf
          
2.1.0.RELEASE
net.sourceforge.nekohtml
nekohtml
1.9.22

在application.properties中添加:

#启动检查spring.thymeleaf.check-template=true#模板spring.thymeleaf.prefix=classpath:/templates/#文件后缀spring.thymeleaf.suffix=.htmlspring.thymeleaf.mode=LEGACYHTML5spring.thymeleaf.encoding=UTF-8spring.thymeleaf.content-type=text/htmlspring.thymeleaf.cache=falsespring.mvc.view.prefix=/resources/templates/spring.mvc.view.suffix=.htmlspring.mvc.static-path-pattern=/static/**#spring.resources.static-locations=classpath:/static/

 

异常错误:

1. Cannot find template location: classpath:/templates/

  如果在程序中已经引入templates在application.properties中也引入了thymeleaf则:

  问题出在pom.xml  resource在移动资源文件时, templates被忽略所致。

src/main/resources
*.*
static/**
template/**
    
true
src/main/resources
false

 2. 同时注意程序的统一拦截器拦截要加载放行

 参见拦截器配置方面。

 3. 静态资源第一次设置在页面访问可能出现404,可对mvn先进行打包后,再试。 

 

转载于:https://www.cnblogs.com/DennyZhao/p/9699347.html

你可能感兴趣的文章
Java类集框架 —— HashMap源码分析
查看>>
【火炉炼AI】机器学习022-使用均值漂移聚类算法构建模型
查看>>
如何才能弥补实际工作经验不足,而获得一份好工作?
查看>>
基于 CentOS 搭建 WordPress 个人博客
查看>>
WIFI渗透从入门到精通
查看>>
Webscan360的防御与绕过
查看>>
jQuery HTML
查看>>
数据可视化Seaborn从零开始学习教程(二) 颜色调控篇
查看>>
Android 开发推荐
查看>>
异构计算助力客户春节webp图片编码
查看>>
聊聊storm client的nimbus.seeds参数
查看>>
浅度理解NodeJS的HTTP模块
查看>>
多迪技术总监告诉你为什么人工智能用Python?
查看>>
ES6 系列之迭代器与 for of
查看>>
Java核心(五)深入理解BIO、NIO、AIO
查看>>
使用ELK构建分布式日志分析系统
查看>>
react组件的生命周期
查看>>
笔记-SSZipArchive使用以及遇到的问题
查看>>
了解webpack-4.0版本(一)
查看>>
如何培养良好的编程风格
查看>>