Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the version control of Springboot2 thymeleaf js/css

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Today, I would like to talk to you about the version control of Springboot2 thymeleaf js/css, many people may not know much about it. In order to make you understand better, the editor summarized the following content for you. I hope you can get something according to this article.

1. Enable versioning

Append MD5 code to the request js/css or manually add the version number to ensure that the js/css content can be loaded into the browser in time when the content changes:

Yml configuration spring: thymeleaf: mode: HTML cache: false resources: chain: strategy: content: enabled: true paths: / * * enabled: true cache: false static-locations: classpath:/static/

Or

Java configuration @ Configurationpublic class MvcInterceptorConfig implements WebMvcConfigurer {/ * * feature description *

* .addFixedVersionStrategy ("v1.0.1", "/ * *"): add version number manually * .addContentVersionStrategy ("/ *") is MD5 code *

* * @ 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 page reference

A normal abc.js browser will become abc-83fb8c4d9199dce0224da0206423106f.js (md5) or / v1.0.1/abc.js (add the version number manually) when loaded

3.BUG repair

In general, the above methods can achieve the requirement effect, but in the actual development process, the above configuration may not take effect due to relatively complex scenarios, which can be solved by adding the following Bean

@ SpringBootApplicationpublic class XxxApplication {public static void main (String [] args) {SpringApplication.run (XxxApplication.class, args);} / * function description *

* add static resource md5 version control *

* * @ author wandoupeas * @ date 2019-11-06 * @ since 2019-11-06 * / @ Bean public ResourceUrlEncodingFilter resourceUrlEncodingFilter () {return new ResourceUrlEncodingFilter ();}

The article is written in OpenWrite

After reading the above, do you have any further understanding of Springboot2 thymeleaf js/css version control? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report