Springboot2 thymeleaf js/css的版本控制是怎样的
发表于:2024-10-23 作者:千家信息网编辑
千家信息网最后更新 2024年10月23日,今天就跟大家聊聊有关Springboot2 thymeleaf js/css的版本控制是怎样的,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。1
千家信息网最后更新 2024年10月23日Springboot2 thymeleaf js/css的版本控制是怎样的
今天就跟大家聊聊有关Springboot2 thymeleaf js/css的版本控制是怎样的,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
1.启用版本控制
通过对请求js/css附加md5码或者手动添加版本号方式来保证在js/css内容发生变更时能及时被浏览器加载到:
yml配置
spring: thymeleaf: mode: HTML cache: false resources: chain: strategy: content: enabled: true paths: /** enabled: true cache: false static-locations: classpath:/static/
或
java配置
@Configurationpublic class MvcInterceptorConfig implements WebMvcConfigurer { /** * 功能描述 ** .addFixedVersionStrategy("v1.0.1", "/**") 为手动添加版本号方式 * .addContentVersionStrategy("/**") 为md5码方式 *
* * @param registry registry * @return void * @author wandoupeas * @date 2019-11-06 * @since 2019-11-06 */ @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/**") .addResourceLocations("classpath:/static/") .resourceChain(false) .addResolver(new VersionResourceResolver()// .addFixedVersionStrategy("v1.0.1", "/**") .addContentVersionStrategy("/**") ); }}
2.Thymeleaf页面引用
正常的abc.js浏览器加载时会变成abc-83fb8c4d9199dce0224da0206423106f.js(md5)或/v1.0.1/abc.js(手动添加版本号)
3.BUG修复
以上方式一般情况下就可以达到需求效果,但是在实际开发过程中由于相对复杂的场景导致以上配置可能会不生效,通过添加以下Bean
就能解决
@SpringBootApplicationpublic class XxxApplication { public static void main(String[] args) { SpringApplication.run(XxxApplication.class, args); } /** * 功能描述 ** 添加静态资源md5版本控制 *
* * @author wandoupeas * @date 2019-11-06 * @since 2019-11-06 */ @Bean public ResourceUrlEncodingFilter resourceUrlEncodingFilter() { return new ResourceUrlEncodingFilter(); }}
文章使用OpenWrite进行编写
看完上述内容,你们对Springboot2 thymeleaf js/css的版本控制是怎样的有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。
版本
控制
内容
方式
手动
配置
功能
浏览器
浏览
复杂
场景
实际
情况
效果
文章
是在
更多
知识
篇文章
行业
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
重庆网络安全公司简介
数据库技术发展成熟阶段
连接到orcl数据库
服务器租用管理员好吗
骆驼互联网科技
提供垃圾分类软件开发
服务器k8s节点
网络安全几点建议
远程桌面服务器管理器打不开
三种常用数据库模型
数据库表一对一关系
网络技术安全专业
bentham数据库
开发者海南劭赢网络技术
什么专业学网络技术
上位机程序用什么软件开发
数据库安全的第一道
云服务器屏蔽地域
模仿一个软件开发是否侵权
台州直销软件开发价格行情
激光软件开发公司
数据库中查询成绩最高分
诚信经营桌面共享软件开发
你认为什么是逻辑数据库
软件开发简历如何写
爱思唯尔的查重数据库
区块链数据库交互线程
成都服务器容量升级
失落的方舟显示服务器身份验证失败
网络安全职责莫忽视