SpringMVC 3.1中是否有一些注释可以关闭MVC控制器方法上的浏览器缓存?
@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>