日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

JAVA中自己写的util中的chop,Java StringUtils.chop方法代碼示例

發布時間:2025/3/12 java 13 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JAVA中自己写的util中的chop,Java StringUtils.chop方法代碼示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

import org.apache.commons.lang3.StringUtils; //導入方法依賴的package包/類

/**

* Tutti i file dentro a /res vengono indicati come cacheabili lato browser per 1 anno (tramite l'header expires).

* Per evitare che nuove versioni non vengano mai prese, si usa il "trucco" di indicare il numero di build nell'url, così cambiando

* la build cambia l'url e la cache del browser va in miss la prima volta.

* Per sfruttare questo meccanismo bisogna usare lo YadaDialect con l'attributo yada:href, che si comporta come il th:href ma inserisce

* il numero di build nell'url calcolata. Per esempio: yada:href="@{/res/img/favicon.ico}"

* Stessa cosa per yada:src

* I file dentro a /static, invece, non cambiano mai nemmeno alle nuove release (anche se in cache stanno solo 100 giorni). Però non è per questo che si usa static, ma per il fatto che dentro ai commenti condizionali

* non si possono usare i tag thymeleaf, per cui ad esempio html5shiv.js viene messo in /static

*/

@Override

public void addResourceHandlers(ResourceHandlerRegistry registry) {

// The official versioning code doesn't seem to work properly: even when adding a ResourceUrlEncodingFilter to rewrite links

// See:

// https://spring.io/blog/2014/07/24/spring-framework-4-1-handling-static-web-resources

// http://docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#mvc-config-static-resources

//registry.addResourceHandler("/resources/**").addResourceLocations("/META-INF/")

//.setCachePeriod(8640000) // 100 days cache period

//.resourceChain(false).addResolver(new VersionResourceResolver().addFixedVersionStrategy(config.getApplicationBuild(), "/**/"));

String res = STATIC_RESOURCES_FOLDER;

if (res.endsWith("/")) {

res = StringUtils.chop(res); // Remove last character

}

registry.addResourceHandler(res + "-" + config.getApplicationBuild() + "/**").addResourceLocations(res+"/").setCachePeriod(8640000); // 100 days cache period

// Uso "-?*/**" per matchare anche eventuali versioni vecchie che qualcuno potrebbe avere in cache

// Non si può fare perché non matcha

// registry.addResourceHandler(res + "-*/**").addResourceLocations(res+"/").setCachePeriod(31556926); // 1 year cache period

String s = STATIC_FILE_FOLDER;

if (s.endsWith("/")) {

s = StringUtils.chop(s); // Remove last character

}

registry.addResourceHandler(s + "/**").addResourceLocations(s+"/").setCachePeriod(8640000); // 100 days cache period

// yadares prende le risorse dal classpath

String yadares = STATIC_YADARESOURCES_FOLDER;

if (yadares.endsWith("/")) {

yadares = StringUtils.chop(res); // Remove last character

}

registry.addResourceHandler(yadares + "-" + config.getYadaVersion() + "/**").addResourceLocations("classpath:" + YadaConstants.YADA_VIEW_PREFIX+"/yada/").setCachePeriod(8640000); // 100 days cache period

// Handling the "contents" uploaded locally

// NOTE: if you don't need versioning but are happy with the apache file handling, just let apache serve the contents

if (config.isContentUrlLocal()) {

String contentUrl = config.getContentUrl();

// TODO The problem with contents is that the version should be taken from the file timestamp so here it should accept any value but I don't know how to make it work with any version value

registry.addResourceHandler(contentUrl + "/**").addResourceLocations("file:"+config.getContentPath() + "/").setCachePeriod(8640000); // 100 days cache period

}

// robots.txt is usually added by the deploy script depending on the environment

registry.addResourceHandler("/robots.txt").addResourceLocations("/").setCachePeriod(86400); // 1 day cache period

}

總結

以上是生活随笔為你收集整理的JAVA中自己写的util中的chop,Java StringUtils.chop方法代碼示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。