SpringMVC 3.1 中是否有一些注释可以关闭 MVC Controller 方法上的浏览器缓存?
@Controller
@RequestMapping("/status")
public class StatusController {
@RequestMapping(method=RequestMethod.GET)
//anyway to have an annotation here that turns of all the http caching headers?
public String get()
{
// do some work here
return "status";
}
}
最佳答案
据我所知,没有注释,但有一种方法可以使用拦截器通过 XML 对其进行配置。例如:
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/status"/>
<bean id="noCacheWebContentInterceptor"
class="com.nyx.spring.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="0"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptor>
</mvc:interceptors>
关于http - 是否有用于关闭浏览器响应缓存的 spring 3.1 MVC 注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8950542/