方法一:
本人解决的方法,保证可用。
添加过滤器(代码如下)
package com.cn.util;
import java.io.* ;
import javax.servlet.* ;
import javax.servlet.http.HttpServletResponse;
public class ForceNoCacheFilter implements Filter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException
{
((HttpServletResponse) response).setHeader("Cache-Control","no-cache");
((HttpServletResponse) response).setHeader("Pragma","no-cache");
((HttpServletResponse) response).setDateHeader ("Expires", -1);
filterChain.doFilter(request, response);
}
public void destroy()
{
}
public void init(FilterConfig filterConfig) throws ServletException
{
}
}
然后在web.xml中添加这个过滤器
<filter>
<filter-name>NoCache</filter-name>
<filter-class>com.cn.util.ForceNoCacheFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>NoCache</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
com.cn.util.ForceNoCacheFilter为刚才过滤器的包名.类名,/*为匹配所有请求。
这样你所有的请求都将会传到服务器处理,不会查看缓存了。
方法二:
inComeHttp.url="familyGroup.do?method=query&tmp="+Math.random();
url上随意传一个随机数