页面有年月两个下拉列表。和页面打印的当前月的日期表。每个日期都可设置为休日或出勤日。如果后退的话会发生数据混乱。如何像网上银行一样不可以后退。看了几篇,禁止后退是不可能的。有效的办法是禁止页面缓存,JSP有什么有效的方法。javascript的那些方法不管用。糊弄人的办法都是,解决不了根本问题。
------解决方案--------------------
网上搜的,你试试行吗
response.setHeader( "Pragma ", "No-cache "); //禁止http1.1缓存
response.setHeader( "Cache-Control ", "no-cache "); //禁止http1.2缓存
response.setDateHeader( "Expires ", 0); //禁止proxy缓存
把上边三行代码加到你要禁止缓存的jsp页面最上边就可以了。
------解决方案--------------------
这个不好使,我用
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
这个版本写的jsp,加上
<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "cache-control " content= "no-cache ">
<meta http-equiv= "expires " content= "0 ">
这三个条件,后退没影响~~~根本不起作用!
------解决方案--------------------
<body onbeforeunload= "window.location.replace( ' ') ">
onbeforeunload="history.go(0)&
------解决方案--------------------
使用filter
web.xml增加
<filter>
<filter-name> requestEncodingFilter </filter-name>
<filter-class> filters.http.RequestEncodingFilter </filter-class>
</filter>
<filter-mapping>
<filter-name> requestEncodingFilter </filter-name>
<url-pattern> /* </url-pattern>
</filter-mapping>
<servlet>
新写filter
package filters.http;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
public class RequestEncodingFilter implements Filter {
public RequestEncodingFilter() {
}
public void init(FilterConfig config) throws ServletException {
}
public void destroy() {
}
/**
* 强制设置过期
*/
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
((HttpServletResponse) response).setHeader( "Cache-Control ", "no-cache "); ((HttpServletResponse) response).setHeader( "Pragma ", "no-cache "); ((HttpServletResponse) response).setDateHeader( "Expires ", 0);
request.setCharacterEncoding(encoding);
chain.doFilter(request, response);
}
}
------解决方案--------------------
filter可以用在struts里的
按照我说的配置一下了
对每个请求都会调用这个serverlet
设置页面强制过期