public abstract  class Action extends org.apache.struts.action.Action {
  private String modelname;
  private boolean needCheckRight = true ;
  public Action() {
  }  public abstract  ActionForward prepareData(ActionMapping mapping, org.apache.struts.action.ActionForm form, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException ;  public abstract  ActionForward saveData(ActionMapping mapping, org.apache.struts.action.ActionForm form, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException ;  public ActionForward execute(ActionMapping mapping, org.apache.struts.action.ActionForm form, HttpServletRequest request, HttpServletResponse response) throws  Exception {
    ActionForward aw = null ;    if (form instanceof ActionForm ) {
      ActionForm actionform = (ActionForm)form ;
      boolean readonly = false ;      //first, check the right of the user
      if (needCheckRight) {
        //1, check model name
        if (modelname == null) {
          modelname = mapping.getAttribute();
          if (modelname != null)
            modelname = modelname.toUpperCase();
        }        //2, get user id , and check whether login
        Object obj = request.getSession().getAttribute(Constants.USERID);
        boolean hasLogin = false;
        UsersInfo user = null ;
        if (obj != null && obj instanceof UsersInfo) {
          user = (UsersInfo) obj;
          hasLogin = (user.getUsername() != null &&
                      user.getUsername().length() > 0);
        }        //2.1 if not login, the send direct to login page
        if (!hasLogin) {
          return mapping.findForward("login") ;
        }        //3,check right
        String rightType = Security.getRightType(request, null , user.getUserid(), modelname, actionform.getAction()) ;
        boolean hasRight = Security.getRight(user.getUserid() , modelname , actionform.getAction(), rightType );
        request.setAttribute("SECURITYRIGHTTYPE" , rightType);        if (!hasRight ) {
          boolean needdirect = true ;
          //if has not right , but need check has right to view ?
          if (actionform.getAction() != null && actionform.getAction().equalsIgnoreCase(Constants.ACTION_EDIT ) ) {
            if (Security.getRight(request , user.getUserid() , modelname, Constants.ACTION_VIEW ) ) {
              readonly = true ;
              needdirect = false ;
            }
          }          if (needdirect) {
            request.setAttribute("MODELNAME" , modelname);
            return mapping.findForward("noright") ;
          }
        }
      }
//这段代码起什么作用!!!!!!!!!!!!!!!!1
      switch (actionform.getActionphase()) {
        case 0:
        case 1:
          aw = this.prepareData(mapping,form,request,response) ;
          actionform.setActionphase(2);
          break;
        case 2:
          if (!readonly)
          aw = this.saveData(mapping,form,request,response) ;
          request.getSession().removeAttribute(form.getClass().getName());
          break;
      }      if (readonly) {
        actionform.setAction(Constants.ACTION_VIEW);
        request.setAttribute(Constants.ACTION_VIEW , Constants.ACTION_VIEW);
      }else {
        request.setAttribute(Constants.ACTION_VIEW , actionform.getAction());
      }    } else {
      System.out.println("all actionForm must be inherited from nsk actionform!");
    }    return aw ;
  }
  public ActionForward perform(ActionMapping mapping, org.apache.struts.action.ActionForm form, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException {
    try {
      return execute(mapping, form, request, response);
    }catch (Exception ex) {
      return null ;
    }
  }
  public String getModelname() {
    return modelname;
  }
  public void setModelname(String modelname) {
    this.modelname = modelname;
  }
  public boolean isNeedCheckRight() {
    return needCheckRight;
  }
  public void setNeedCheckRight(boolean needCheckRight) {
    this.needCheckRight = needCheckRight;
  }  protected String getDataSourceName(HttpServletRequest request) throws java.sql.SQLException {
      if (request == null || request.getSession().getAttribute(Constants.DATASOURCE_KEY) == null ) {
        throw new java.sql.SQLException("Can not find the datasource name!");
      }else {
        return (String)request.getSession().getAttribute(Constants.DATASOURCE_KEY) ;
      }
    }
}在LogingAction开头有
if (loginform.getActionphase() != 2 ) {
      httpServletRequest.getSession().invalidate();
      httpServletRequest.getSession(true) ;
      loginform.setActionphase(2);
      return actionMapping.getInputForward() ;
    }