LoginInterceptor interceptor coding (in)

Fame and the other two classes methods omitted here.

// processing is executed before execution

    // login intercepts, verify permissions

   @Override

   public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object arg2) throws Exception {

     

      Object attribute = request.getSession().getAttribute("username");

       if(attribute != null){

        // release, execute processor

        return true;

       }else{

           response.sendRedirect(request.getContextPath() + "/user/tologin.action");

        // release, execute processor

        return false;

       }

   }

 

Guess you like

Origin www.cnblogs.com/yuwenweisan/p/10939073.html