`
Listen_ing
  • 浏览: 35341 次
  • 性别: Icon_minigender_1
  • 来自: 郑州
社区版块
存档分类
最新评论

LoginInterceptor (用户登录拦截器类)

 
阅读更多
public class LoginInterceptor extends MethodFilterInterceptor {


    @Override
    protected String doIntercept(ActionInvocation invocation) throws Exception {
       // TODO Auto-generated method stub
       ActionContext context = invocation.getInvocationContext();
       Map session = context.getSession();
      
       try {
           TbUser user = (TbUser) session.get("user");
           if (user != null) {
             
              return invocation.invoke();
           }
           else {
              context.put("login"," please to login again" );
              return ActionSupport.LOGIN;
           }
       } catch (Exception e) {
           // TODO: handle exception
           context.put("login"," please to login again" );
           return ActionSupport.LOGIN;
       }
    }




}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics