论坛首页 Java企业应用论坛

构建一个通用的Action 类,请大家谈谈自己的看法和经验

浏览 21663 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-07-16  

如果为第个Form都建一个Action那是相当麻烦的,

如果像下面这样构建啦一个通用的Action会带来什么好处?

而像平常的做法是几乎是一个Form 和 Action的这种做法又有什么好处?
 
请大家谈谈自己的看法和经验?

下面是源码和相关的解释

请大家先看一下Struts-config.xml 中的一部分内容

xml 代码
  1. <!--第一种 parameter为空并且name为空时的情况 即 form=null 时 直接转发-->  
  2.     <action path="/dgroom/index" type="com.dgroom.struts.BeanAction"  
  3.       validate="false" >  
  4.       <forward name="success" path="/dgroom/index.xsp"/>  
  5.     </action>  
  6. <!--第二种情况 parameter="*"时 意为想调用一个Bean但又不想调用他里面的任何方法时 -->  
  7.    <action path="/dgroom/loginForm" type="com.dgroom.struts.BeanAction"  
  8.       name="accountBean" scope="session" parameter="*"  
  9.       validate="false">  
  10.       <forward name="success" path="/account/loginForm.xsp"/>  
  11.     </action>  
  12. <!--第三种 当  parameter="  NAME  " 有值时 调用 accountBean中的displayAll()方法-->  
  13.     <action path="/dgroom/displayAllAccount" type="com.dgroom.struts.BeanAction"  
  14.       name="accountBean" scope="session" parameter="displayAll"  
  15.       validate="false">  
  16.       <forward name="success" path="/dgroom/displayAll.xsp"/>  
  17.     </action>  
  18. <!--第四种  就直接调用地址栏中的最后的那个 login()方法 -->  
  19.     <action path="/dgroom/login" type="com.dgroom.struts.BeanAction"  
  20.       name="accountBean" scope="session"  
  21.       validate="false">  
  22.       <forward name="success" path="/dgroom/index.xsp"/>  
  23.     </action>  

而在其它的Bean中的方法也如同下面的这个方法,都是返回一个字符串

而在AccountBean.java中的方法如下

java 代码
  1. public class AccountBean   
  2. {   
  3.     public String login(){   
  4.         if(){   
  5.             //成功   
  6.             return "success";   
  7.         }   
  8.         //失败   
  9.         return "failure";   
  10.     }   
  11. }   

下面的是通用的 BeanAction.java 类

java 代码
  1. package com.dgroom.struts;   
  2. import org.apache.struts.action.Action;   
  3. import org.apache.struts.action.ActionForm;   
  4. import org.apache.struts.action.ActionForward;   
  5. import org.apache.struts.action.ActionMapping;   
  6.   
  7. import javax.servlet.http.HttpServletRequest;   
  8. import javax.servlet.http.HttpServletResponse;   
  9. import java.lang.reflect.Method;   
  10.   
  11. import com.dgroom.util.*;   
  12.   
  13. public class BeanAction extends Action {   
  14.   
  15.   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)   
  16.       throws Exception {   
  17.   
  18.     String forward = "success";   
  19.     try {   
  20.         //这里是对ActionContext.save(request,reponse);   
  21.         //对映 Struts-config.xml 中的 第一种 :当请求中的 Form 为空时直接转 发   
  22.       if (form != null) {   
  23.         Method method = null;   
  24.         String methodName = mapping.getParameter();   
  25.   
  26.         //第三种:当参数中存在着某个值时并且不等于 * 时就直接调用那个参数中的方法   
  27.         if (methodName != null && !"*".equals(methodName)) {   
  28.           try {   
  29.             method = form.getClass().getMethod(methodName, null);   
  30.             forward = (String) method.invoke(form, null);   
  31.           } catch (Exception e) {   
  32.            // 这里是一个自定义的异常   
  33.           }   
  34.         }   
  35.         //第四种 当参数为空时 直接调用地址栏最后的方法   
  36.         if (method == null && !"*".equals(methodName)) {   
  37.           methodName = mapping.getPath();   
  38.           if (methodName.length() > 1) {   
  39.             int slash = methodName.lastIndexOf("/") + 1;   
  40.             methodName = methodName.substring(slash);   
  41.             if (methodName.length() > 0) {   
  42.               try {                
  43.                 method = form.getClass().getMethod(methodName, null);                  
  44.                 forward = (String) method.invoke(form, null);   
  45.               } catch (Exception e) {   
  46.                // 这里是一个自定义的异常   
  47.               }   
  48.             }   
  49.           }   
  50.         }   
  51.       }   
  52.   
  53.     } catch (Exception e) {   
  54.   
  55.       // 这里是一个自定义的异常   
  56.       throw e;   
  57.     }   
  58.   
  59.     return mapping.findForward(forward);   
  60.   }   
  61.   
  62. }   
   发表时间:2007-07-16  
你还是看看dispathAction和dynamicFormBean吧
0 请登录后投票
   发表时间:2007-07-16  

Map model = JspUtil.getRequestModel(request);
  //把request参数塞到map里
    ORM.insert(tableName,model);
    //ORM.update(tableName,model);
     //orm 是diy的ORM小工具
0 请登录后投票
   发表时间:2007-07-16  
要想通用太难了。。就我个人在开发中碰到的问题,动态方法,include,download等action的功能要整合在一起就很麻烦。至于在dispatchAction下,由于form的invalidate方法出错后,返回的input页面如何解决
0 请登录后投票
   发表时间:2007-07-16  
flxi78 写道
要想通用太难了。。就我个人在开发中碰到的问题,动态方法,include,download等action的功能要整合在一起就很麻烦。至于在dispatchAction下,由于form的invalidate方法出错后,返回的input页面如何解决


其实这就是一个通用的Action
我是在Jpetstore上分析源码时发现的,觉得很好就发上来与大家共享

你上面所说的返回input页面如何解决?
因上面有一段代码我把它注释啦 ActionContext.save(request.response);
这是把所传过来的 request和response进行保存

而当页面出错的时候是通过ActionContext来保存的,并且是在login()方法中进行保存

由于关联的代码太多,我就只发这个最主要的上来
0 请登录后投票
   发表时间:2007-07-17  
ActionContext是struts 1.X提供的类么?我好像找不到。
另外,我看楼主的思路是通过自己写一个bean(这个bean还没有继承ActionFrom,我记得好像struts调用这个bean的时候,会报错。),然后在bean当中定义业务方法。最后通过反射方式去访问bean的业务方法.
我个人从类的数量上来说,form是没有减少工作量的,但是Action的确可以减少一些。但是这样的做法引起更多的一些不方便。因为你的业务方法,比如说login是在bean里面的,那如何访问一些request和response的东西?比如request.getParameterValues,该问题或许可以在反射调用时把request, response都传到bean的业务方法里去来解决;那么又如何访问一些Action提供的一些方法呢?比如action.getLocale(Request reqeust)? 我们也得在反射调用时把action传到bean的业务方法里?
那么如果这样的话,struts1.X提供的一些action,比如IncludeAction,DownloadAction,DispatchAction,我们怎么使用?
楼主想通过一个Action,把由此引起的调用压力全部释放到bean上去,我还是会觉得这个bean的代码会比较凌乱。
0 请登录后投票
   发表时间:2007-07-17  
ActionContext不是Struts当中的类,
这是一个自定义的类,这个类用来保存一些错误的信息
初始化request和response

你所说的在Bean中的业务方法是增加啦不少的代码~
至于如何调用action的一些方法,这里没有仔细想过
你说到的这几个问题很好,点醒啦我
0 请登录后投票
   发表时间:2007-07-17  
这样做是不是让MVC结构更模糊了?Action应该是显示层的组间,返回值forward定义了要将结过呈现出来的页面。
由后台Bean来决定forward的值,增加了显示层和后台模型层的耦合。这样会影响到系统组间的可重用性。对项目的成本和效率都会造成一定影响吧。
0 请登录后投票
   发表时间:2007-07-17  
要避免写 Action 是不可能的,最好是写一个项目中通用的 Action,提供大量已实现的方法。其他 Action 都从此继承,这样要好写得多。

(不要引用这个回复啊,会死人的)

java 代码
 
  1. package com.chinacreator.ccimp.common.struts;  
  2.   
  3. import com.chinacreator.ccimp.common.ErrorReporter;  
  4. import com.chinacreator.ccimp.common.page.PageHelper;  
  5. import com.chinacreator.ccimp.CcimpException;  
  6. import com.chinacreator.commons.beans.NameValuePair;  
  7. import com.chinacreator.commons.utils.StringUtil;  
  8. import com.chinacreator.security.AccessControl;  
  9. import org.apache.log4j.Logger;  
  10. import org.apache.struts.action.Action;  
  11. import org.apache.struts.action.ActionForm;  
  12. import org.apache.struts.action.ActionForward;  
  13. import org.apache.struts.action.ActionMapping;  
  14. import org.apache.commons.fileupload.FileItem;  
  15. import org.apache.commons.fileupload.FileItemFactory;  
  16. import org.apache.commons.fileupload.FileUploadException;  
  17. import org.apache.commons.fileupload.servlet.ServletFileUpload;  
  18. import org.apache.commons.fileupload.disk.DiskFileItemFactory;  
  19.   
  20. import javax.servlet.http.HttpServletRequest;  
  21. import javax.servlet.http.HttpServletResponse;  
  22. import javax.servlet.ServletException;  
  23. import java.util.ArrayList;  
  24. import java.util.Enumeration;  
  25. import java.util.List;  
  26. import java.io.IOException;  
  27.   
  28. /** 
  29.  * 信息平台使用的 struts Action 类。本类包含大量方法方便处理请求、校验参数、写业务日志等。 
  30.  * <p/> 
  31.  * 使用时只需实现 execute 方法即可。 
  32.  * <p/> 
  33.  * 本类已经实现对访问权限的控制,不需要再写。 
  34.  * 如果要获取参数,使用 getParam() 方法即可。 
  35.  * 如果要向 request 存储数据,使用 setAttribute() 方法即可。 
  36.  * 如果要校验参数,实现 validate() 方法即可。validate() 方法没有返回值,校验失败时请抛出异常。 
  37.  * 建议使用 assertExists()、assertTrue() 等方法校验参数。 
  38.  * 
  39.  * @author hyd 
  40.  */  
  41. public abstract class CcimpAction extends Action {  
  42.   
  43.     static Logger log = Logger.getLogger(CcimpAction.class);  
  44.   
  45.     /** 
  46.      * 防止重复提交的标识 
  47.      */  
  48.     public static final String REQUEST_TOKEN = "duplicate_request_token";  
  49.   
  50.     /** 
  51.      * 预定义的 forward 
  52.      */  
  53.     protected static final String SUCCESS = "success";  
  54.   
  55.     public static boolean SHOW_PARAMS = false;  
  56.   
  57.     protected static ThreadLocal helperContainer = new ThreadLocal();  
  58.     protected static ThreadLocal errorsContainer = new ThreadLocal();  
  59.   
  60.     public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,  
  61.                                  HttpServletResponse response) throws Exception {  
  62.         request.setCharacterEncoding("GBK");  
  63.         response.setContentType("text/html; charset=GBK");  
  64.         response.setHeader("Pragma""No-cache");  
  65.         response.setHeader("Cache-Control""no-cache");  
  66.         response.setDateHeader("Expires"0);  
  67.   
  68.         String forward = "error";  
  69.         PageHelper helper = new PageHelper(request, response);  
  70.         helperContainer.set(helper);  
  71.         log.debug("当前 Action:" + this.getClass().getName());  
  72.   
  73.         // 检查用户是否登录  
  74.         if (!helper.checkAccess()) {  
  75.             log.debug("用户未登录,页面访问被阻止。");  
  76.             return mapping.findForward("login");  
  77.         }  
  78.   
  79.         TokenManager tm = new TokenManager(request);  
  80.         if (!tm.isTokenValid()) {  
  81.             log.debug("重复提交被阻止。");  
  82.             setAttribute("result""不允许重复提交。");  
  83.             return mapping.findForward(forward);  
  84.         }  
  85.         tm.saveToken();  
  86.   
  87.         // 在后台输出请求参数  
  88.         if (SHOW_PARAMS) {  
  89.             log.debug("请求参数:\n" + getRequestParamsString());  
  90.         }  
  91.   
  92.         // 进行参数校验  
  93.         try {  
  94.             validate(form);  
  95.             ArrayList errors = getErrors();  
  96.             if (errors.size() > 0) {  
  97.                 StringBuffer buffer = new StringBuffer();  
  98.                 for (int i = 0; i < errors.size(); i++) {  
  99.                     String msg = (String) errors.get(i);  
  100.                     buffer.append(msg).append("\n");  
  101.                 }  
  102.                 String result = buffer.toString();  
  103.                 log.error("参数验证失败:" + result);  
  104.                 setAttribute("result", result);  
  105.                 return mapping.findForward(forward);  
  106.             }  
  107.         } catch (Exception e) {  
  108.             setAttribute("result", e.getMessage());  
  109.             return mapping.findForward(forward);  
  110.         }  
  111.   
  112.         // 执行子类实现的预处理  
  113.         preProcess();  
  114.   
  115.         try {  
  116.             forward = execute(form);  
  117.         } catch (Exception e) {  
  118.             reportError(e);  
  119.             throw e;  
  120.         }  
  121.         return mapping.findForward(forward);  
  122.     }  
  123.   
  124.     private void reportError(Exception e) {  
  125.         log.warn("发送错误报告...");  
  126.         ErrorReporter.report(getRequest().getRequestURI(), e);  
  127.     }  
  128.   
  129.     protected String getRequestParamsString() {  
  130.         NameValuePair[] params = getHelper().getAllParams();  
  131.         StringBuffer buffer = new StringBuffer();  
  132.         for (int i = 0; i < params.length; i++) {  
  133.             NameValuePair param = params[i];  
  134.             buffer.append("setRequestParam(\"")  
  135.                     .append(param.getName())  
  136.                     .append("\", \"")  
  137.                     .append(param.getValue())  
  138.                     .append("\");\n");  
  139.         }  
  140.         return buffer.toString();  
  141.     }  
  142.   
  143.     protected void addError(String message) {  
  144.         ArrayList errors = getErrors();  
  145.         errors.add(message);  
  146.     }  
  147.   
  148.     /** 
  149.      * 检查参数是否为空 
  150.      * 
  151.      * @param paramName   request 中的参数名 
  152.      * @param failMessage 如果参数为空,则向用户显示的错误讯息 
  153.      * 
  154.      * @throws ValidationFailException 如果参数为空 
  155.      */  
  156.     protected void assertExists(String paramName, String failMessage) throws ValidationFailException {  
  157.         assertTrue(paramExists(paramName), failMessage);  
  158.     }  
  159.   
  160.     /** 
  161.      * 检查参数是否符合条件 
  162.      * 
  163.      * @param expression  检查表达式 
  164.      * @param failMessage 如果不符合条件,则向用户显示的错误讯息 
  165.      * 
  166.      * @throws ValidationFailException 如果不符合条件 
  167.      */  
  168.     protected void assertTrue(boolean expression, String failMessage) throws ValidationFailException {  
  169.         if (!expression) {  
  170.             throw new ValidationFailException(failMessage);  
  171.         }  
  172.     }  
  173.   
  174.     /** 
  175.      * 检查参数是否符合条件 
  176.      * 
  177.      * @param expression  检查表达式 
  178.      * @param failMessage 如果不符合条件,则向用户显示的错误讯息 
  179.      * 
  180.      * @throws ValidationFailException 如果不符合条件 
  181.      */  
  182.     protected void assertFalse(boolean expression, String failMessage) throws ValidationFailException {  
  183.         assertTrue(!expression, failMessage);  
  184.     }  
  185.   
  186.     /** 
  187.      * 检查参数是否为空 
  188.      * 
  189.      * @param value       参数值 
  190.      * @param failMessage 如果参数为空,则向用户显示的错误讯息 
  191.      * 
  192.      * @throws ValidationFailException 如果参数为空 
  193.      */  
  194.     protected void assertNotEmpty(String value, String failMessage) throws ValidationFailException {  
  195.         assertTrue(!StringUtil.isEmptyString(value), failMessage);  
  196.     }  
  197.   
  198.     /** 
  199.      * 检查数组是否为空 
  200.      * 
  201.      * @param values      数组 
  202.      * @param failMessage 如果数组为空,则向用户显示的错误讯息 
  203.      * 
  204.      * @throws ValidationFailException 如果数组为空 
  205.      */  
  206.     protected void assertNotEmpty(String[] values, String failMessage) throws ValidationFailException {  
  207.         assertTrue(values != null && values.length > 0, failMessage);  
  208.     }  
  209.   
  210.     protected ArrayList getErrors() {  
  211.         ArrayList list = (ArrayList) getRequest().getAttribute("CCIMP_REQUEST_ERRORS");  
  212.         if (list == null) {  
  213.             list = new ArrayList();  
  214.             getRequest().setAttribute("CCIMP_REQUEST_ERRORS", list);  
  215.         }  
  216.         return list;  
  217.     }  
  218.   
  219.     /** 
  220.      * 获得一个 AccessControl 实例 
  221.      * 
  222.      * @return 一个 AccessControl 实例 
  223.      */  
  224.     protected AccessControl getAccessControl() {  
  225.         return getHelper().getAccessControl();  
  226.     }  
  227.   
  228.     /** 
  229.      * 获得请求对象 
  230.      * 
  231.      * @return 请求对象 
  232.      */  
  233.     protected HttpServletRequest getRequest() {  
  234.         return getHelper().getRequest();  
  235.     }  
  236.   
  237.     /** 
  238.      * 获得回应对象 
  239.      * 
  240.      * @return 回应对象 
  241.      */  
  242.     protected HttpServletResponse getResponse() {  
  243.         return getHelper().getResponse();  
  244.     }  
  245.   
  246.     /** 
  247.      * 将对象放入 request 
  248.      * 
  249.      * @param name  名称 
  250.      * @param value 对象 
  251.      */  
  252.     protected void setAttribute(String name, Object value) {  
  253.         getRequest().setAttribute(name, value);  
  254.     }  
  255.   
  256.     /** 
  257.      * 将数值放入 request 
  258.      * 
  259.      * @param name 名称 
  260.      * @param num  数值 
  261.      */  
  262.     protected void setAttribute(String name, int num) {  
  263.         setAttribute(name, new Integer(num));  
  264.     }  
  265.   
  266.     /** 
  267.      * 将 boolean 值放入 request 
  268.      * 
  269.      * @param name 名称 
  270.      * @param b    boolean 值 
  271.      */  
  272.     protected void setAttribute(String name, boolean b) {  
  273.         setAttribute(name, Boolean.valueOf(b));  
  274.     }  
  275.   
  276.     /** 
  277.      * 获得 request 中的值 
  278.      * 
  279.      * @param name 名称 
  280.      * 
  281.      * @return request 中的值 
  282.      */  
  283.     protected Object getAttribute(String name) {  
  284.         return getRequest().getAttribute(name);  
  285.     }  
  286.   
  287.     // 获得请求参数  
  288.     protected String getParam(String name) {  
  289.         return getHelper().getParam(name);  
  290.     }  
  291.   
  292.     // 获得请求参数  
  293.     protected String getParamFromRequestAndSession(String name) {  
  294.         String value = getHelper().getParam(name);  
  295.         if (StringUtil.isEmptyString(value)) {  
  296.             value = StringUtil.replaceNull(getSessionAttributeOnce(name));  
  297.         }  
  298.         return value;  
  299.     }  
  300.   
  301.     // 获得请求参数  
  302.     protected String getParam(String name, Object defaultValue) {  
  303.         return getHelper().getParam(name, StringUtil.replaceNull(defaultValue));  
  304.     }  
  305.   
  306.     // 获得请求参数  
  307.     protected String[] getParamValues(String name) {  
  308.         return getHelper().getParamValues(name);  
  309.     }  
  310.   
  311.     protected String getSessionString(String name) {  
  312.         return getHelper().getSessionString(name);  
  313.     }  
  314.   
  315.     protected String[] getParamNames() {  
  316.         ArrayList nameArr = new ArrayList();  
  317.         Enumeration names = getRequest().getParameterNames();  
  318.         while (names.hasMoreElements()) {  
  319.             nameArr.add(names.nextElement());  
  320.         }  
  321.         return (String[]) nameArr.toArray(new String[nameArr.size()]);  
  322.     }  
  323.   
  324.     /** 
  325.      * 设置处理结果信息 
  326.      * 
  327.      * @param message 处理结果信息(如“记录添加成功!”等,用于显示在页面上) 
  328.      */  
  329.     protected void setActionMessage(String message) {  
  330.         setSessionAttribute("ccimp_message"new Message(Message.INFO, message));  
  331.     }  
  332.   
  333.     /** 
  334.      * 设置处理结果信息 
  335.      * 
  336.      * @param message 处理结果信息(如“记录添加成功!”等,用于显示在页面上) 
  337.      */  
  338.     protected void setActionMessage(Message message) {  
  339.         setSessionAttribute("ccimp_message", message);  
  340.     }  
  341.   
  342.     /** 
  343.      * 设置处理结果错误信息 
  344.      * 
  345.      * @param message 处理结果错误信息(如“记录添加失败:ID 重复”等,用于显示在页面上) 
  346.      */  
  347.     protected void setActionErrorMessage(String message) {  
  348.         setSessionAttribute("ccimp_message"new Message(Message.ERROR, message));  
  349.     }  
  350.   
  351.     /** 
  352.      * 设置是否进行访问权限的检查。单元测试中应将其设置为false。 
  353.      * 
  354.      * @param validation 是否进行访问权限的检查 
  355.      */  
  356.     public void setAccessValidation(boolean validation) {  
  357.         getHelper().setAccessValidation(validation);  
  358.     }  
  359.   
  360.     public void setHelper(PageHelper h) {  
  361.         helperContainer.set(h);  
  362.     }  
  363.   
  364.     protected PageHelper getHelper() {  
  365.         return (PageHelper) helperContainer.get();  
  366.     }  
  367.   
  368.     /** 
  369.      * 执行请求 
  370.      * 
  371.      * @param form 表单 
  372.      * 
  373.      * @return 要跳转的 forward 名称 
  374.      * 
  375.      * @throws Exception 如果执行失败 
  376.      */  
  377.     public abstract String execute(ActionForm form) throws Exception;  
  378.   
  379.     /** 
  380.      * 执行请求之前的预处理 
  381.      */  
  382.     protected void preProcess() {  
  383.         // 给子类使用  
  384.     }  
  385.   
  386.     /** 
  387.      * 校验参数 
  388.      * 
  389.      * @param form 表单 
  390.      * 
  391.      * @throws Exception 如果执行校验失败 
  392.      */  
  393.     protected void validate(ActionForm form) throws Exception {  
  394.         // 给子类使用  
  395.     }  
  396.   
  397.     /** 
  398.      * 写业务日志 
  399.      * 
  400.      * @param action  动作 
  401.      * @param object  对象 
  402.      * @param message 日志信息 
  403.      */  
  404.     protected void log(String action, String object, String message) {  
  405.         getHelper().writeLog(action, object, message);  
  406.     }  
  407.   
  408.     /** 
  409.      * 写业务日志 
  410.      * 
  411.      * @param action  动作 
  412.      * @param message 日志信息 
  413.      */  
  414.     protected void log(String action, String message) {  
  415.         log(action, "", message);  
  416.     }  
  417.   
  418.     /** 
  419.      * 设置 session 属性 
  420.      * 
  421.      * @param name  属性名称 
  422.      * @param value 属性值 
  423.      */  
  424.     protected void setSessionAttribute(String name, Object value) {  
  425.         getRequest().getSession().setAttribute(name, value);  
  426.     }  
  427.   
  428.     /** 
  429.      * 获得 session 属性 
  430.      * 
  431.      * @param name 属性名 
  432.      * 
  433.      * @return 属性值 
  434.      */  
  435.     protected Object getSessionAttribute(String name) {  
  436.         return getRequest().getSession().getAttribute(name);  
  437.     }  
  438.   
  439.     /** 
  440.      * 获得 session 属性,只取一次 
  441.      * 
  442.      * @param name 属性名 
  443.      * 
  444.      * @return 属性值 
  445.      */  
  446.     protected Object getSessionAttributeOnce(String name) {  
  447.         Object value = getRequest().getSession().getAttribute(name);  
  448.         getRequest().getSession().removeAttribute(name);  
  449.         return value;  
  450.     }  
  451.   
  452.     /** 
  453.      * 检查当前用户是否拥有指定操作的权限 
  454.      * 
  455.      * @param
0 请登录后投票
   发表时间:2007-08-22  
<div class="code_title">要避免写 Action 是不可能的,最好是写一个项目中通用的 Action,提供大量已实现的方法。其他 Action 都从此继承,这样要好写得多。<br />
<br />
(不要引用这个回复啊,会死人的)<br />
<br />
java 代码</div>
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol start="1" class="dp-j">
    <li class="alt"><span><span class="keyword">package</span><span>&nbsp;com.chinacreator.ccimp.common.struts;&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;com.chinacreator.ccimp.common.ErrorReporter;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;com.chinacreator.ccimp.common.page.PageHelper;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;com.chinacreator.ccimp.CcimpException;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;com.chinacreator.commons.beans.NameValuePair;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;com.chinacreator.commons.utils.StringUtil;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;com.chinacreator.security.AccessControl;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;org.apache.log4j.Logger;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;org.apache.struts.action.Action;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;org.apache.struts.action.ActionForm;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;org.apache.struts.action.ActionForward;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;org.apache.struts.action.ActionMapping;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;org.apache.commons.fileupload.FileItem;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;org.apache.commons.fileupload.FileItemFactory;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;org.apache.commons.fileupload.FileUploadException;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;org.apache.commons.fileupload.servlet.ServletFileUpload;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;org.apache.commons.fileupload.disk.DiskFileItemFactory;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;javax.servlet.http.HttpServletRequest;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;javax.servlet.http.HttpServletResponse;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;javax.servlet.ServletException;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;java.util.ArrayList;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;java.util.Enumeration;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;java.util.List;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;java.io.IOException;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span><span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;*&nbsp;信息平台使用的&nbsp;struts&nbsp;Action&nbsp;类。本类包含大量方法方便处理请求、校验参数、写业务日志等。</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;*&nbsp;&lt;p/&gt;</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;*&nbsp;使用时只需实现&nbsp;execute&nbsp;方法即可。</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;*&nbsp;&lt;p/&gt;</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;*&nbsp;本类已经实现对访问权限的控制,不需要再写。</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;*&nbsp;如果要获取参数,使用&nbsp;getParam()&nbsp;方法即可。</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;*&nbsp;如果要向&nbsp;request&nbsp;存储数据,使用&nbsp;setAttribute()&nbsp;方法即可。</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;*&nbsp;如果要校验参数,实现&nbsp;validate()&nbsp;方法即可。validate()&nbsp;方法没有返回值,校验失败时请抛出异常。</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;*&nbsp;建议使用&nbsp;assertExists()、assertTrue()&nbsp;等方法校验参数。</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;*&nbsp;@author&nbsp;hyd</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">abstract</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;CcimpAction&nbsp;</span><span class="keyword">extends</span><span>&nbsp;Action&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">static</span><span>&nbsp;Logger&nbsp;log&nbsp;=&nbsp;Logger.getLogger(CcimpAction.</span><span class="keyword">class</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;防止重复提交的标识</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">final</span><span>&nbsp;String&nbsp;REQUEST_TOKEN&nbsp;=&nbsp;</span><span class="string">&quot;duplicate_request_token&quot;</span><span>;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;预定义的&nbsp;forward</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">final</span><span>&nbsp;String&nbsp;SUCCESS&nbsp;=&nbsp;</span><span class="string">&quot;success&quot;</span><span>;&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">boolean</span><span>&nbsp;SHOW_PARAMS&nbsp;=&nbsp;</span><span class="keyword">false</span><span>;&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;ThreadLocal&nbsp;helperContainer&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;ThreadLocal();&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;ThreadLocal&nbsp;errorsContainer&nbsp;=&nbsp;</span><span class="keyword">new</span><span>&nbsp;ThreadLocal();&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;ActionForward&nbsp;execute(ActionMapping&nbsp;mapping,&nbsp;ActionForm&nbsp;form,&nbsp;HttpServletRequest&nbsp;request,&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HttpServletResponse&nbsp;response)&nbsp;<span class="keyword">throws</span><span>&nbsp;Exception&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;request.setCharacterEncoding(<span class="string">&quot;GBK&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setContentType(<span class="string">&quot;text/html;&nbsp;charset=GBK&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setHeader(<span class="string">&quot;Pragma&quot;</span><span>,&nbsp;</span><span class="string">&quot;No-cache&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setHeader(<span class="string">&quot;Cache-Control&quot;</span><span>,&nbsp;</span><span class="string">&quot;no-cache&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;response.setDateHeader(<span class="string">&quot;Expires&quot;</span><span>,&nbsp;</span><span class="number">0</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;forward&nbsp;=&nbsp;<span class="string">&quot;error&quot;</span><span>;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PageHelper&nbsp;helper&nbsp;=&nbsp;<span class="keyword">new</span><span>&nbsp;PageHelper(request,&nbsp;response);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helperContainer.set(helper);&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug(<span class="string">&quot;当前&nbsp;Action:&quot;</span><span>&nbsp;+&nbsp;</span><span class="keyword">this</span><span>.getClass().getName());&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;检查用户是否登录</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(!helper.checkAccess())&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug(<span class="string">&quot;用户未登录,页面访问被阻止。&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;mapping.findForward(</span><span class="string">&quot;login&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;TokenManager&nbsp;tm&nbsp;=&nbsp;<span class="keyword">new</span><span>&nbsp;TokenManager(request);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(!tm.isTokenValid())&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug(<span class="string">&quot;重复提交被阻止。&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttribute(<span class="string">&quot;result&quot;</span><span>,&nbsp;</span><span class="string">&quot;不允许重复提交。&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;mapping.findForward(forward);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;tm.saveToken();&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;在后台输出请求参数</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(SHOW_PARAMS)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.debug(<span class="string">&quot;请求参数:\n&quot;</span><span>&nbsp;+&nbsp;getRequestParamsString());&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;进行参数校验</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;validate(form);&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ArrayList&nbsp;errors&nbsp;=&nbsp;getErrors();&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(errors.size()&nbsp;&gt;&nbsp;</span><span class="number">0</span><span>)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StringBuffer&nbsp;buffer&nbsp;=&nbsp;<span class="keyword">new</span><span>&nbsp;StringBuffer();&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">for</span><span>&nbsp;(</span><span class="keyword">int</span><span>&nbsp;i&nbsp;=&nbsp;</span><span class="number">0</span><span>;&nbsp;i&nbsp;&lt;&nbsp;errors.size();&nbsp;i++)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;msg&nbsp;=&nbsp;(String)&nbsp;errors.get(i);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer.append(msg).append(<span class="string">&quot;\n&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;result&nbsp;=&nbsp;buffer.toString();&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.error(<span class="string">&quot;参数验证失败:&quot;</span><span>&nbsp;+&nbsp;result);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttribute(<span class="string">&quot;result&quot;</span><span>,&nbsp;result);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;mapping.findForward(forward);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttribute(<span class="string">&quot;result&quot;</span><span>,&nbsp;e.getMessage());&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;mapping.findForward(forward);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;执行子类实现的预处理</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;preProcess();&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">try</span><span>&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;forward&nbsp;=&nbsp;execute(form);&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<span class="keyword">catch</span><span>&nbsp;(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;reportError(e);&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">throw</span><span>&nbsp;e;&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;mapping.findForward(forward);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">private</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;reportError(Exception&nbsp;e)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log.warn(<span class="string">&quot;发送错误报告...&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ErrorReporter.report(getRequest().getRequestURI(),&nbsp;e);&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;String&nbsp;getRequestParamsString()&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NameValuePair[]&nbsp;params&nbsp;=&nbsp;getHelper().getAllParams();&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;StringBuffer&nbsp;buffer&nbsp;=&nbsp;<span class="keyword">new</span><span>&nbsp;StringBuffer();&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">for</span><span>&nbsp;(</span><span class="keyword">int</span><span>&nbsp;i&nbsp;=&nbsp;</span><span class="number">0</span><span>;&nbsp;i&nbsp;&lt;&nbsp;params.length;&nbsp;i++)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NameValuePair&nbsp;param&nbsp;=&nbsp;params[i];&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer.append(<span class="string">&quot;setRequestParam(\&quot;&quot;</span><span>)&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.append(param.getName())&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.append(<span class="string">&quot;\&quot;,&nbsp;\&quot;&quot;</span><span>)&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.append(param.getValue())&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.append(<span class="string">&quot;\&quot;);\n&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;buffer.toString();&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;addError(String&nbsp;message)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ArrayList&nbsp;errors&nbsp;=&nbsp;getErrors();&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;errors.add(message);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;检查参数是否为空</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;paramName&nbsp;&nbsp;&nbsp;request&nbsp;中的参数名</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;failMessage&nbsp;如果参数为空,则向用户显示的错误讯息</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@throws&nbsp;ValidationFailException&nbsp;如果参数为空</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;assertExists(String&nbsp;paramName,&nbsp;String&nbsp;failMessage)&nbsp;</span><span class="keyword">throws</span><span>&nbsp;ValidationFailException&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertTrue(paramExists(paramName),&nbsp;failMessage);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;检查参数是否符合条件</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;expression&nbsp;&nbsp;检查表达式</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;failMessage&nbsp;如果不符合条件,则向用户显示的错误讯息</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@throws&nbsp;ValidationFailException&nbsp;如果不符合条件</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;assertTrue(</span><span class="keyword">boolean</span><span>&nbsp;expression,&nbsp;String&nbsp;failMessage)&nbsp;</span><span class="keyword">throws</span><span>&nbsp;ValidationFailException&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(!expression)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">throw</span><span>&nbsp;</span><span class="keyword">new</span><span>&nbsp;ValidationFailException(failMessage);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;检查参数是否符合条件</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;expression&nbsp;&nbsp;检查表达式</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;failMessage&nbsp;如果不符合条件,则向用户显示的错误讯息</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@throws&nbsp;ValidationFailException&nbsp;如果不符合条件</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;assertFalse(</span><span class="keyword">boolean</span><span>&nbsp;expression,&nbsp;String&nbsp;failMessage)&nbsp;</span><span class="keyword">throws</span><span>&nbsp;ValidationFailException&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertTrue(!expression,&nbsp;failMessage);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;检查参数是否为空</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;value&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;参数值</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;failMessage&nbsp;如果参数为空,则向用户显示的错误讯息</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@throws&nbsp;ValidationFailException&nbsp;如果参数为空</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;assertNotEmpty(String&nbsp;value,&nbsp;String&nbsp;failMessage)&nbsp;</span><span class="keyword">throws</span><span>&nbsp;ValidationFailException&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertTrue(!StringUtil.isEmptyString(value),&nbsp;failMessage);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;检查数组是否为空</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;values&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;数组</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;failMessage&nbsp;如果数组为空,则向用户显示的错误讯息</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@throws&nbsp;ValidationFailException&nbsp;如果数组为空</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;assertNotEmpty(String[]&nbsp;values,&nbsp;String&nbsp;failMessage)&nbsp;</span><span class="keyword">throws</span><span>&nbsp;ValidationFailException&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;assertTrue(values&nbsp;!=&nbsp;<span class="keyword">null</span><span>&nbsp;&amp;&amp;&nbsp;values.length&nbsp;&gt;&nbsp;</span><span class="number">0</span><span>,&nbsp;failMessage);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;ArrayList&nbsp;getErrors()&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ArrayList&nbsp;list&nbsp;=&nbsp;(ArrayList)&nbsp;getRequest().getAttribute(<span class="string">&quot;CCIMP_REQUEST_ERRORS&quot;</span><span>);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(list&nbsp;==&nbsp;</span><span class="keyword">null</span><span>)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;list&nbsp;=&nbsp;<span class="keyword">new</span><span>&nbsp;ArrayList();&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getRequest().setAttribute(<span class="string">&quot;CCIMP_REQUEST_ERRORS&quot;</span><span>,&nbsp;list);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;list;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;获得一个&nbsp;AccessControl&nbsp;实例</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;一个&nbsp;AccessControl&nbsp;实例</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;AccessControl&nbsp;getAccessControl()&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getHelper().getAccessControl();&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;获得请求对象</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;请求对象</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;HttpServletRequest&nbsp;getRequest()&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getHelper().getRequest();&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;获得回应对象</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;回应对象</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;HttpServletResponse&nbsp;getResponse()&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getHelper().getResponse();&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;将对象放入&nbsp;request</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;name&nbsp;&nbsp;名称</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;value&nbsp;对象</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setAttribute(String&nbsp;name,&nbsp;Object&nbsp;value)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getRequest().setAttribute(name,&nbsp;value);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;将数值放入&nbsp;request</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;name&nbsp;名称</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;num&nbsp;&nbsp;数值</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setAttribute(String&nbsp;name,&nbsp;</span><span class="keyword">int</span><span>&nbsp;num)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttribute(name,&nbsp;<span class="keyword">new</span><span>&nbsp;Integer(num));&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;将&nbsp;boolean&nbsp;值放入&nbsp;request</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;name&nbsp;名称</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;b&nbsp;&nbsp;&nbsp;&nbsp;boolean&nbsp;值</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setAttribute(String&nbsp;name,&nbsp;</span><span class="keyword">boolean</span><span>&nbsp;b)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setAttribute(name,&nbsp;Boolean.valueOf(b));&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;获得&nbsp;request&nbsp;中的值</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;name&nbsp;名称</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;request&nbsp;中的值</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;Object&nbsp;getAttribute(String&nbsp;name)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getRequest().getAttribute(name);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;获得请求参数</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;String&nbsp;getParam(String&nbsp;name)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getHelper().getParam(name);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;获得请求参数</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;String&nbsp;getParamFromRequestAndSession(String&nbsp;name)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;value&nbsp;=&nbsp;getHelper().getParam(name);&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">if</span><span>&nbsp;(StringUtil.isEmptyString(value))&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value&nbsp;=&nbsp;StringUtil.replaceNull(getSessionAttributeOnce(name));&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;value;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;获得请求参数</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;String&nbsp;getParam(String&nbsp;name,&nbsp;Object&nbsp;defaultValue)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getHelper().getParam(name,&nbsp;StringUtil.replaceNull(defaultValue));&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;获得请求参数</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;String[]&nbsp;getParamValues(String&nbsp;name)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getHelper().getParamValues(name);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;String&nbsp;getSessionString(String&nbsp;name)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getHelper().getSessionString(name);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;String[]&nbsp;getParamNames()&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ArrayList&nbsp;nameArr&nbsp;=&nbsp;<span class="keyword">new</span><span>&nbsp;ArrayList();&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Enumeration&nbsp;names&nbsp;=&nbsp;getRequest().getParameterNames();&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">while</span><span>&nbsp;(names.hasMoreElements())&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nameArr.add(names.nextElement());&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;(String[])&nbsp;nameArr.toArray(</span><span class="keyword">new</span><span>&nbsp;String[nameArr.size()]);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;设置处理结果信息</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;message&nbsp;处理结果信息(如&ldquo;记录添加成功!&rdquo;等,用于显示在页面上)</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setActionMessage(String&nbsp;message)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setSessionAttribute(<span class="string">&quot;ccimp_message&quot;</span><span>,&nbsp;</span><span class="keyword">new</span><span>&nbsp;Message(Message.INFO,&nbsp;message));&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;设置处理结果信息</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;message&nbsp;处理结果信息(如&ldquo;记录添加成功!&rdquo;等,用于显示在页面上)</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setActionMessage(Message&nbsp;message)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setSessionAttribute(<span class="string">&quot;ccimp_message&quot;</span><span>,&nbsp;message);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;设置处理结果错误信息</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;message&nbsp;处理结果错误信息(如&ldquo;记录添加失败:ID&nbsp;重复&rdquo;等,用于显示在页面上)</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setActionErrorMessage(String&nbsp;message)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;setSessionAttribute(<span class="string">&quot;ccimp_message&quot;</span><span>,&nbsp;</span><span class="keyword">new</span><span>&nbsp;Message(Message.ERROR,&nbsp;message));&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;设置是否进行访问权限的检查。单元测试中应将其设置为false。</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;validation&nbsp;是否进行访问权限的检查</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setAccessValidation(</span><span class="keyword">boolean</span><span>&nbsp;validation)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getHelper().setAccessValidation(validation);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setHelper(PageHelper&nbsp;h)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;helperContainer.set(h);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;PageHelper&nbsp;getHelper()&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;(PageHelper)&nbsp;helperContainer.get();&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;执行请求</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;form&nbsp;表单</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;要跳转的&nbsp;forward&nbsp;名称</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@throws&nbsp;Exception&nbsp;如果执行失败</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">abstract</span><span>&nbsp;String&nbsp;execute(ActionForm&nbsp;form)&nbsp;</span><span class="keyword">throws</span><span>&nbsp;Exception;&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;执行请求之前的预处理</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;preProcess()&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;给子类使用</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;校验参数</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;form&nbsp;表单</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@throws&nbsp;Exception&nbsp;如果执行校验失败</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;validate(ActionForm&nbsp;form)&nbsp;</span><span class="keyword">throws</span><span>&nbsp;Exception&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;给子类使用</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;写业务日志</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;action&nbsp;&nbsp;动作</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;object&nbsp;&nbsp;对象</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;message&nbsp;日志信息</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;log(String&nbsp;action,&nbsp;String&nbsp;object,&nbsp;String&nbsp;message)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getHelper().writeLog(action,&nbsp;object,&nbsp;message);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;写业务日志</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;action&nbsp;&nbsp;动作</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;message&nbsp;日志信息</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;log(String&nbsp;action,&nbsp;String&nbsp;message)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;log(action,&nbsp;<span class="string">&quot;&quot;</span><span>,&nbsp;message);&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;设置&nbsp;session&nbsp;属性</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;name&nbsp;&nbsp;属性名称</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;value&nbsp;属性值</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;setSessionAttribute(String&nbsp;name,&nbsp;Object&nbsp;value)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getRequest().getSession().setAttribute(name,&nbsp;value);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;获得&nbsp;session&nbsp;属性</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;name&nbsp;属性名</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;属性值</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;Object&nbsp;getSessionAttribute(String&nbsp;name)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;getRequest().getSession().getAttribute(name);&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;获得&nbsp;session&nbsp;属性,只取一次</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;name&nbsp;属性名</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@return&nbsp;属性值</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">protected</span><span>&nbsp;Object&nbsp;getSessionAttributeOnce(String&nbsp;name)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Object&nbsp;value&nbsp;=&nbsp;getRequest().getSession().getAttribute(name);&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getRequest().getSession().removeAttribute(name);&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">return</span><span>&nbsp;value;&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;</span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;检查当前用户是否拥有指定操作的权限</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;
1 请登录后投票
论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics