Topic: 关于JSP刷新的问题(阻止IE缓存jsp文件)

  Print this page

1.关于JSP刷新的问题(阻止IE缓存jsp文件) Copy to clipboard
Posted by: javaspirit
Posted on: 2003-10-22 11:04

我做个WEB应用程序,按照道理不同身份登录看到的是不同的界面,但是登录后看到的是前面已经登录的人的界面,要手动刷新一下才可以看到,我用的FORM的POST的方法可以,但是用HREF就不行了。有人能帮助我吗,谢谢!

2.Re:关于JSP刷新的问题,我快疯了,有人能帮兄弟我吗? [Re: javaspirit] Copy to clipboard
Posted by: linux_china
Posted on: 2003-10-22 11:33

是浏览器的问题:
浏览器一般会对get的页面会进行缓存,而对post的页面不会进行缓存!
应该适应一下浏览器的这个特性,不然的客户一个个设定就麻烦啦!

Blush 但愿对你有帮助!

3.Re:关于JSP刷新的问题,我快疯了,有人能帮兄弟我吗? [Re: javaspirit] Copy to clipboard
Posted by: javaspirit
Posted on: 2003-10-22 11:40

我是在两台机器上试的,是不是Tomcat的问题呀?

4.Re:关于JSP刷新的问题,我快疯了,有人能帮兄弟我吗? [Re: javaspirit] Copy to clipboard
Posted by: dapan
Posted on: 2003-10-22 12:14

不是tomcat的问题,是缓存的问题。
搜索一下论坛。

^_^

5.Re:关于JSP刷新的问题,我快疯了,有人能帮兄弟我吗? [Re: javaspirit] Copy to clipboard
Posted by: javaspirit
Posted on: 2003-10-22 12:28

是tomcat的缓存问题吗,没有找到啊,dapan能替我找找吗?

6.Re:关于JSP刷新的问题,我快疯了,有人能帮兄弟我吗? [Re: javaspirit] Copy to clipboard
Posted by: dapan
Posted on: 2003-10-22 13:31

nocache.jsp:

<%
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>
<meta http-equiv="Expires" content="-10">
<meta http-equiv="Pragma" content="No-cache">
<meta http-equiv="Cache-Control", "private">

其他页面:
<include...>

7.Re:关于JSP刷新的问题,我快疯了,有人能帮兄弟我吗? [Re: javaspirit] Copy to clipboard
Posted by: javaspirit
Posted on: 2003-10-22 15:45

谢谢,dapan,问题已经解决。
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Cache-Control", "must-revalidate");
response.setDateHeader("Expires",0);
将上面代码放入jsp页面中,强制浏览器访问此页面的最新内容,而不是从缓冲里去取。
http://www.cjsdn.com/post/view?bid=1&id=14682&tpg=1&ppg=1&sty=1&age=30#14682

<meta http-equiv='Expires' content='0'>
<meta http-equiv='Pragma' content='No-cache'>
<meta http-equiv='Cache-Control' content='No-cache'>
这几句作用不清楚,但是还是加进去了。

8.Re:关于JSP刷新的问题,我快疯了,有人能帮兄弟我吗? [Re: javaspirit] Copy to clipboard
Posted by: nothing
Posted on: 2003-10-22 15:55

这两组是一样的,只是JSP和HTML的不同解决方案.

9.Re:关于JSP刷新的问题(阻止IE缓存jsp文件) [Re: javaspirit] Copy to clipboard
Posted by: yiqiang
Posted on: 2003-10-23 15:06

put a time parameter in your link href attribute.
for example:
<A href="http://xxxxxll.jsp?linkTime="+<%=System.currentTimeMillis()%>>link string</A>

By doing this can keep your link is always different with that lasted user clicked one.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923