在jsp页面上调用
$.getJSON("${ctx}/getData.action", {topId:topId}, function(json){
//使用返回数据更新页面
}
发现页面有缓存的现象,即更换用户登录后数据不变。
开始以为是jpa缓存了,关闭jpa缓存,不起作用。
又尝试关闭ie缓存,呵呵,生效了。(在浏览器ie选项中设置)
于是在jsp设置页面不缓存
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
以为问题就这样解决了,但登录页面发现依旧缓存
后来怀疑是不是json缓存了,经测试,getJSON的回调方法可要执行
但getData.action里的代码没有被执行,所以判断是json缓存了。
在
PrintWriter out = response.getWriter();
out.write(json);
之前加上禁止json缓存的代码
response.setHeader("pragma", "no-cache");
response.setHeader("cache-control", "no-no-cache");
response.setHeader("expires", "0");
问题解决。