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方法代碼示例相关推荐

  1. java中setid(),Java Process.setId方法代碼示例

    本文整理匯總了Java中org.activiti.bpmn.model.Process.setId方法的典型用法代碼示例.如果您正苦於以下問題:Java Process.setId方法的具體用法?Ja ...

  2. java中reject方法作用_Java BindingResult.rejectValue方法代碼示例

    本文整理匯總了Java中org.springframework.validation.BindingResult.rejectValue方法的典型用法代碼示例.如果您正苦於以下問題:Java Bind ...

  3. java中elements_Java Element.elements方法代碼示例

    本文整理匯總了Java中org.dom4j.Element.elements方法的典型用法代碼示例.如果您正苦於以下問題:Java Element.elements方法的具體用法?Java Eleme ...

  4. java中prtintln_Java Element.attributeValue方法代碼示例

    本文整理匯總了Java中org.dom4j.Element.attributeValue方法的典型用法代碼示例.如果您正苦於以下問題:Java Element.attributeValue方法的具體用 ...

  5. java中stopwatch,Java StopWatch.stop方法代碼示例

    本文整理匯總了Java中org.hsqldb.lib.StopWatch.stop方法的典型用法代碼示例.如果您正苦於以下問題:Java StopWatch.stop方法的具體用法?Java Stop ...

  6. java中getbest_Java Highlighter.getBestFragment方法代碼示例

    本文整理匯總了Java中org.apache.lucene.search.highlight.Highlighter.getBestFragment方法的典型用法代碼示例.如果您正苦於以下問題:Jav ...

  7. python中startout是什么意思_Python socket.timeout方法代碼示例

    本文整理匯總了Python中gevent.socket.timeout方法的典型用法代碼示例.如果您正苦於以下問題:Python socket.timeout方法的具體用法?Python socket ...

  8. java版本的getorcreate_Java ContainerUtil.getOrCreate方法代碼示例

    本文整理匯總了Java中com.intellij.util.containers.ContainerUtil.getOrCreate方法的典型用法代碼示例.如果您正苦於以下問題:Java Contai ...

  9. java digests.generatesalt_Java DigestUtils.sha1Hex方法代碼示例

    本文整理匯總了Java中org.apache.commons.codec.digest.DigestUtils.sha1Hex方法的典型用法代碼示例.如果您正苦於以下問題:Java DigestUti ...

  10. java createfile,Java Filer.createSourceFile方法代碼示例

    本文整理匯總了Java中javax.annotation.processing.Filer.createSourceFile方法的典型用法代碼示例.如果您正苦於以下問題:Java Filer.crea ...

最新文章

  1. NTU商汤提出新 loss!提升图像重建和图像合成的质量 (ICCV2021)
  2. ubuntu安装mysql报错_在Ubuntu上安装mysql数据库和遇到的问题
  3. break和continue特殊玩法“标签”
  4. C++中public,protected,private派生类继承问题和访问权限问题
  5. 统计一个数的补码中二进制中1的个数
  6. java jstack 死锁_利用jstack检测死锁DeadLock
  7. java基础基础总结----- Date
  8. 组合查询--表单对象转化为json数组
  9. MySQL Index Merge Optimization
  10. MFC模态对话与非模态对话框(二)
  11. v-distpicker 直辖市的修改
  12. 高中数学:抛物线专题讲解利用韦达定理求解技巧
  13. win10去除桌面快捷方式图标(亲测可用)
  14. 智能客服在2022:从成本中心奔向价值中心
  15. 大数据招聘信息可视化
  16. 虹科PCAN在工程机械中的应用
  17. r语言把两个折线图图像放到一个图里_图像目标检测算法总结(从R-CNN到YOLO v3)...
  18. Smarting:第一款真正意义上的便携式可移动脑电设备
  19. 离散数学图论旅行规划问题_旅游路径规划问题.pdf
  20. 个人总结向-毕业设计开题报告格式

热门文章

  1. 第 1-1 课:Java 程序是如何执行的?
  2. 我写了10年博客,却被人说“不火”?我是这样怼回去的?
  3. Html 按钮button加超链接
  4. [下载]青岛交通旅游地图[download]
  5. 简单的ajax上传商品功能使用SevletFileUpload和FormData
  6. alxctools索引超出了数组界限_[译]V8中的数组类型
  7. 计算机维护系统Win8PE,win8如何进入PE重装电脑系统
  8. python字符串类型_Python3的字符串类型(疯狂Python)
  9. 电脑练习打字软件_Type Fu for Mac 4.5.7 共享版 – 优秀的键盘打字练习软件
  10. Win11如何将游戏隐藏 Win11游戏隐藏的方法