这是action的中代码 public String out() throws IOException{
HttpServletRequest request=ServletActionContext.getRequest();
request.setCharacterEncoding("utf-8");
HttpServletResponse response= ServletActionContext.getResponse();
response.setCharacterEncoding("gbk");
PrintWriter out=ServletActionContext.getResponse().getWriter();
ActionContext.getContext().getSession().remove("user_login");
ActionContext.getContext().getSession().clear();
out.write("<script language='javascript'>parent.window.document.location.location='/HaiMen/login.jsp';</script> ");
return null;
}这是过滤器的代码out.print("<script>alert('请先登陆');parent.window.document.location='/HaiMen/login.jsp';</script>");
HttpServletRequest request=ServletActionContext.getRequest();
request.setCharacterEncoding("utf-8");
HttpServletResponse response= ServletActionContext.getResponse();
response.setCharacterEncoding("gbk");
PrintWriter out=ServletActionContext.getResponse().getWriter();
ActionContext.getContext().getSession().remove("user_login");
ActionContext.getContext().getSession().clear();
out.write("<script language='javascript'>parent.window.document.location.location='/HaiMen/login.jsp';</script> ");
return null;
}这是过滤器的代码out.print("<script>alert('请先登陆');parent.window.document.location='/HaiMen/login.jsp';</script>");
你可以使用location.replace("newurl")防止点击后退,注意这个代码写的位置。写到前面的页面才有效