使用frameset,怎么在session,timeout后,点击任何链接都能整体返回index页面
项目中遇到这个问题:session-timeout后,操作左菜单原来页面,会弹出一个新的登录页面在target=“NT_PHVIEW”,而不是,一个新的整体登录页面,
解决方案:
在我自定义的SessionFilter里加了这么一段代码:
package com.alu.gm.filter;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
import com.alu.gm.util.LdapUtil;
public class SessionFilter implements Filter
{
public void init(FilterConfig fConfig) throws ServletException { }
public void doFilter(ServletRequest req, ServletResponse res, FilterChain fChain) throws IOException, ServletException
{
HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res;
String uri = request.getRequestURI();
String contextPath = request.getContextPath();
if (!uri.equals(contextPath+"/index.jsp")
&& !uri.equals(contextPath+"/LoginServlet")
&& !uri.equals(contextPath+"/LogoutServlet")
&& !uri.equals(contextPath+"/images/logo_alcatel-lucent-2lines.gif"))
{
HttpSession session = request.getSession(false);
if (session == null || session.getAttribute(LdapUtil.LOGIN_PERSON) == null) // Check if it has passed validation
{
clearCache(response); // Clear cache before forwarding
// request.getRequestDispatcher("/index.jsp").forward(request, response);
PrintWriter out=res.getWriter();
out.println("<script>");
out.println("window.top.location.href='index.jsp';");
out.println("</script>");
return;
}
}
fChain.doFilter(req, res);
}
/** Clear cache for client browser */
public void clearCache(HttpServletResponse response)
{
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", -10);
}
public void destroy() { }
}
附网上资料:
关于js中window.location.href,location.href,parent.location.href,top.location.href的用法"window.location.href"、"location.href"是本页面跳转."parent.location.href" 是上一层页面跳转."top.location.href" 是最外层的页面跳转.举例说明: 如果A,B,C,D都是html,D是C的iframe,C是B的iframe,B是A的iframe,如果D中js这样写 "window.location.href"、"location.href":D页面跳转 "parent.location.href":C页面跳转 "top.location.href":A页面跳转如果D页面中有form的话, <form>: form提交后D页面跳转 <form target="_blank">: form提交后弹出新页面 <form target="_parent">: form提交后C页面跳转 <form target="_top"> : form提交后A页面跳转