日期:2014-05-16 浏览次数:20613 次
<package name="json-nocache" extends="json-default"> <interceptors> <interceptor name="cachingHeadersInterceptor" class="com.ssa.pct.web.interceptor.CachingHeaderInterceptor" /> <interceptor-stack name="defaultSecurityStack"> <interceptor-ref name="defaultStack" /> <interceptor-ref name="cachingHeadersInterceptor" /> </interceptor-stack> </interceptors> <default-interceptor-ref name="defaultSecurityStack" /> </package>
public class CachingHeaderInterceptor extends AbstractInterceptor { private static final long serialVersionUID = 1L; public String intercept(ActionInvocation invocation) throws Exception { ActionContext context = invocation.getInvocationContext(); HttpServletResponse response = (HttpServletResponse) context.get(StrutsStatics.HTTP_RESPONSE); if (response != null) { response.setHeader("Cache-Control", "no-cache"); response.setHeader("Pragma", "no-cache"); response.setHeader("Expires", "-1"); } return invocation.invoke(); } }