在main.jsp头部包含
<logic:notPresent name="<%=com.astro.util.AppConstants.ADMIN%>" scope="session">
<logic:forward name="failure"/>
</logic:notPresent>
<logic:notPresent name="<%=com.astro.util.AppConstants.ADMIN%>" scope="session">
<logic:forward name="failure"/>
</logic:notPresent>
我暂时也在用这样的方法,不过我做了一个check jsp,然后各个页面include一下<%@ include file="redirect(needReLogin).jsp" %>
redirect(needReLogin).jsp:
<%
Object checkedForm = request.getSession().getAttribute("checkedForm");
if(checkedForm == null)
{
RequestDispatcher rd = request.getRequestDispatcher("error(needReLogin).jsp");
rd.forward(request,response);
}
%>
这和你给出的使用struts的logic的思路差不多但是并不能根本解决问题,比如当session过期的时候,我在下面的frame(不妨假设只有header和body两个frame)发出了一个跳转的req,这时候由于session过期,filter就会把下面的frame redirect 到login,而此时header仍然存在着...我一直在想,能不能在filter类中做些手脚,比如判断request来至于sub frame,然后redirect parent?呵呵,想不通,就上来找大家讨论一下,希望各位继续帮忙~
if(self.location.href!=top.location.href)
top.location.href=self.location.href;