为了判断登录和session是否过期我用了个全局拦截器,配置如下:
<interceptor-config>
<interceptor name="sessionInterceptor" type="com.baobiao.struts.interceptor.SessionInterceptor"/>
<default-interceptors >
<interceptor name="sessionInterceptor"/>
</default-interceptors>
</interceptor-config>
拦截器主要代码如下:
public ActionForward beforeAction(Action action, ActionMapping mapping, ActionForm af, HttpServletRequest request, HttpServletResponse hsr1) throws IOException, ServletException {
HttpSession session = request.getSession();
Admin ad = (Admin) session.getAttribute("userinfo");
if (ad == null) {
return mapping.findForward("noPermission");
}
return null;
}
但是login action是处理登录的,不需要验证session是否存在,怎么才能不拦截它呢?或者有别的思路来处理我的需求。
<interceptor-config>
<interceptor name="sessionInterceptor" type="com.baobiao.struts.interceptor.SessionInterceptor"/>
<default-interceptors >
<interceptor name="sessionInterceptor"/>
</default-interceptors>
</interceptor-config>
拦截器主要代码如下:
public ActionForward beforeAction(Action action, ActionMapping mapping, ActionForm af, HttpServletRequest request, HttpServletResponse hsr1) throws IOException, ServletException {
HttpSession session = request.getSession();
Admin ad = (Admin) session.getAttribute("userinfo");
if (ad == null) {
return mapping.findForward("noPermission");
}
return null;
}
但是login action是处理登录的,不需要验证session是否存在,怎么才能不拦截它呢?或者有别的思路来处理我的需求。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货