我正在尝试在 spring mvc 中添加配置,以便我的静态内容(如 js、图像)将被浏览器缓存。我在 dispatcher-servlet.xml 中添加了以下内容
<beans>
.............
<mvc:interceptors>
<bean id="webContentInterceptor" class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="31556926"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptors>
</beans>
但是我仍然没有看到启用了缓存。我在浏览器调试器中看到以下内容,其中显示 Cache-Control:"no-cache"。
请帮忙 !!!
请您参考如下方法:
您可以使用 mvc:resources 缓存静态文件。
<mvc:resources mapping="/static/**" location="/public-resources/"
cache-period="31556926"/>
<mvc:annotation-driven/>




