[代码] 一、清除页面缓存 在jsp页里
01 | //在jsp页里 |
02 | <% |
03 | response.setHeader( "Pragma" , "No-cache" ); |
04 | response.setHeader( "Cache-Control" , "no-cache" ); |
05 | response.setDateHeader( "Expires" , 0 ); |
06 | response.flushBuffer(); |
07 | %> |
08 | //在html页里 |
09 | <meta http-equiv= "Content-Type" content= "text/html; charset=gb2312" > |
10 | <META HTTP-EQUIV= "Pragma" CONTENT= "no-cache" > |
11 | <META HTTP-EQUIV= "Cache-Control" CONTENT= "no-cache" > |
12 | <META HTTP-EQUIV= "Expires" CONTENT= "0" > |
[代码] 二、清除cookie
1 | <% |
2 | Cookie killMyCookie = new Cookie( "mycookie" , null ); |
3 | killMyCookie.setMaxAge( 0 ); |
4 | killMyCookie.setPath( "/" ); |
5 | response.addCookie(killMyCookie); |
6 | %> |
[代码] 三、清除session
1 | <%@ page language= "java" session= "false" %> |
2 | <% |
3 | session.invalidate(); |
4 | %> |
5 | //在页面关闭时清除session,需要捕获windows.onclose事件,再调用清除session方法 |