我想使我的资产文件夹基础依赖于版本,以防止为我的用户缓存问题。我目前使用spring和servlet.xml来配置我的静态路由。如何在spring-servlet.xml中的静态内容路径中使用变量
这是我目前的配置
<!-- Static routes -->
<mvc:resources mapping="/assets/**" location="/assets/" cache-period="0" />
<mvc:resources mapping="/img/**" location="/assets/img/" cache-period="31556926" />
<mvc:resources location="/assets/img/favicon.ico" mapping="/favicon.ico" />
我想用这样的事情,但我不知道如何配置这一点。
<!-- Static routes -->
<mvc:resources mapping="/assets/${version}/**" location="/assets/" cache-period="0" />
<mvc:resources mapping="/img/**" location="/assets/${version}/img/" cache-period="31556926" />
<mvc:resources location="/assets/${version}/img/favicon.ico" mapping="/favicon.ico" />
version变量在application.properties中定义,我成功地在我的JSP文件中使用它。但我注册我的静态路由似乎不能使用它。请指教。
我认为Spring MVC已经构建了资源缓存清除的功能。看看[这篇文章](http://stackoverflow.com/a/30139512/1291150)或[这一个](https://spring.io/blog/2014/07/24/spring-framework-4 -1-handling-static-web-resources),然后尝试实现一些自定义解决方案。免责声明:我没有亲自尝试过,但它可以帮助你。 [This SO post](http://stackoverflow.com/a/9204940/1291150)如果您决定使用自定义解决方案,则包含对您的问题的解答(mvc:resources中的占位符)。祝你好运! –
谢谢,听起来不错。虽然我可能仍然使用自定义解决方案来运行,但是如果我能够按照版本提供的应用程序的想法工作,那么我可以运行它。 –