`
dongguoh
  • 浏览: 70709 次
  • 性别: Icon_minigender_1
  • 来自: 山水之乡
社区版块
存档分类
最新评论

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

阅读更多

如果为第个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. }   
分享到:
评论
13 楼 ice123456 2007-09-06  
用法:struts.config.xml,定义一个parameter="action"
你可以在你自己写的action里面继承DispatchAction这个类,然后直接写方法,跟继承action是一样的,不同的是方法名可以不一样
你在前台调用的时候是admin.*?action=test
这里就相当于调用你在action写的test方法
12 楼 ice123456 2007-09-06  
我认为你还不如去看下DispatchAction
这个类应该可以达到你想的哪种效果
11 楼 leeon 2007-08-24  
xiaoxiaodi5834 写道
个人认为,你是想用一个通用的Action来替换每个Action,然后再通过这个Action来调用业务类。应该是想再做一层封装。

刚好有用过一个这种框架的东西,即,将Action用一个EJB来实现,将所有的通用的东西放到这里面,来做事务控制。
这个东西理论上是不错的,可是实际上却还是要再多一些配置文件来定义真正业务类的位置的东东。

个人认为,这样子做的效果不是太好。不如直接用Struts2.0



这种框架我们以前做过,用一个通用的Action类,然后通过很多配置文件来描述
具体的service类在什么地方,需要传入什么参数到service中,然后把这些参数
一股脑扔到一个map中在传入service

后来被用过的人一阵狂骂,现在还是回到写action类来,
其实用struts2.0已经可以帮我减少很多麻烦事了,大家用下了都觉得效果不错
10 楼 xiaoxiaodi5834 2007-08-23  
个人认为,你是想用一个通用的Action来替换每个Action,然后再通过这个Action来调用业务类。应该是想再做一层封装。

刚好有用过一个这种框架的东西,即,将Action用一个EJB来实现,将所有的通用的东西放到这里面,来做事务控制。
这个东西理论上是不错的,可是实际上却还是要再多一些配置文件来定义真正业务类的位置的东东。

个人认为,这样子做的效果不是太好。不如直接用Struts2.0
9 楼 sam1982 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;
8 楼 yiding_he 2007-07-17  
<div class='code_title'>要避免写 Action 是不可能的,最好是写一个项目中通用的 Action,提供大量已实现的方法。其他 Action 都从此继承,这样要好写得多。<br/>
<br/>
(不要引用这个回复啊,会死人的)<br/>
<br/>
java 代码</div>
<div class='dp-highlighter'>
<div class='bar'> </div>
<ol class='dp-j' start='1'>
    <li class='alt'><span><span class='keyword'>package</span><span> com.chinacreator.ccimp.common.struts;  </span></span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> com.chinacreator.ccimp.common.ErrorReporter;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> com.chinacreator.ccimp.common.page.PageHelper;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> com.chinacreator.ccimp.CcimpException;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> com.chinacreator.commons.beans.NameValuePair;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> com.chinacreator.commons.utils.StringUtil;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> com.chinacreator.security.AccessControl;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> org.apache.log4j.Logger;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> org.apache.struts.action.Action;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> org.apache.struts.action.ActionForm;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> org.apache.struts.action.ActionForward;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> org.apache.struts.action.ActionMapping;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> org.apache.commons.fileupload.FileItem;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> org.apache.commons.fileupload.FileItemFactory;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> org.apache.commons.fileupload.FileUploadException;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> org.apache.commons.fileupload.servlet.ServletFileUpload;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> org.apache.commons.fileupload.disk.DiskFileItemFactory;  </span></span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span><span class='keyword'>import</span><span> javax.servlet.http.HttpServletRequest;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> javax.servlet.http.HttpServletResponse;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> javax.servlet.ServletException;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> java.util.ArrayList;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> java.util.Enumeration;  </span></span></li>
    <li class='alt'><span><span class='keyword'>import</span><span> java.util.List;  </span></span></li>
    <li class=''><span><span class='keyword'>import</span><span> java.io.IOException;  </span></span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span><span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'> * 信息平台使用的 struts Action 类。本类包含大量方法方便处理请求、校验参数、写业务日志等。</span> </span></li>
    <li class=''><span><span class='comment'> * &lt;p/&gt;</span> </span></li>
    <li class='alt'><span><span class='comment'> * 使用时只需实现 execute 方法即可。</span> </span></li>
    <li class=''><span><span class='comment'> * &lt;p/&gt;</span> </span></li>
    <li class='alt'><span><span class='comment'> * 本类已经实现对访问权限的控制,不需要再写。</span> </span></li>
    <li class=''><span><span class='comment'> * 如果要获取参数,使用 getParam() 方法即可。</span> </span></li>
    <li class='alt'><span><span class='comment'> * 如果要向 request 存储数据,使用 setAttribute() 方法即可。</span> </span></li>
    <li class=''><span><span class='comment'> * 如果要校验参数,实现 validate() 方法即可。validate() 方法没有返回值,校验失败时请抛出异常。</span> </span></li>
    <li class='alt'><span><span class='comment'> * 建议使用 assertExists()、assertTrue() 等方法校验参数。</span> </span></li>
    <li class=''><span><span class='comment'> *</span> </span></li>
    <li class='alt'><span><span class='comment'> * @author hyd</span> </span></li>
    <li class=''><span><span class='comment'> */</span><span>  </span></span></li>
    <li class='alt'><span><span class='keyword'>public</span><span> </span><span class='keyword'>abstract</span><span> </span><span class='keyword'>class</span><span> CcimpAction </span><span class='keyword'>extends</span><span> Action {  </span></span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='keyword'>static</span><span> Logger log = Logger.getLogger(CcimpAction.</span><span class='keyword'>class</span><span>);  </span></span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>/**</span> </span></li>
    <li class=''><span><span class='comment'>     * 防止重复提交的标识</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>final</span><span> String REQUEST_TOKEN = </span><span class='string'>"duplicate_request_token"</span><span>;  </span></span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 预定义的 forward</span> </span></li>
    <li class=''><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>final</span><span> String SUCCESS = </span><span class='string'>"success"</span><span>;  </span></span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='keyword'>public</span><span> </span><span class='keyword'>static</span><span> </span><span class='keyword'>boolean</span><span> SHOW_PARAMS = </span><span class='keyword'>false</span><span>;  </span></span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>static</span><span> ThreadLocal helperContainer = </span><span class='keyword'>new</span><span> ThreadLocal();  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>static</span><span> ThreadLocal errorsContainer = </span><span class='keyword'>new</span><span> ThreadLocal();  </span></span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='keyword'>public</span><span> ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,  </span></span></li>
    <li class='alt'><span>                                 HttpServletResponse response) <span class='keyword'>throws</span><span> Exception {  </span></span></li>
    <li class=''><span>        request.setCharacterEncoding(<span class='string'>"GBK"</span><span>);  </span></span></li>
    <li class='alt'><span>        response.setContentType(<span class='string'>"text/html; charset=GBK"</span><span>);  </span></span></li>
    <li class=''><span>        response.setHeader(<span class='string'>"Pragma"</span><span>, </span><span class='string'>"No-cache"</span><span>);  </span></span></li>
    <li class='alt'><span>        response.setHeader(<span class='string'>"Cache-Control"</span><span>, </span><span class='string'>"no-cache"</span><span>);  </span></span></li>
    <li class=''><span>        response.setDateHeader(<span class='string'>"Expires"</span><span>, </span><span class='number'>0</span><span>);  </span></span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>        String forward = <span class='string'>"error"</span><span>;  </span></span></li>
    <li class='alt'><span>        PageHelper helper = <span class='keyword'>new</span><span> PageHelper(request, response);  </span></span></li>
    <li class=''><span>        helperContainer.set(helper);  </span></li>
    <li class='alt'><span>        log.debug(<span class='string'>"当前 Action:"</span><span> + </span><span class='keyword'>this</span><span>.getClass().getName());  </span></span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>        <span class='comment'>// 检查用户是否登录</span><span>  </span></span></li>
    <li class=''><span>        <span class='keyword'>if</span><span> (!helper.checkAccess()) {  </span></span></li>
    <li class='alt'><span>            log.debug(<span class='string'>"用户未登录,页面访问被阻止。"</span><span>);  </span></span></li>
    <li class=''><span>            <span class='keyword'>return</span><span> mapping.findForward(</span><span class='string'>"login"</span><span>);  </span></span></li>
    <li class='alt'><span>        }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>        TokenManager tm = <span class='keyword'>new</span><span> TokenManager(request);  </span></span></li>
    <li class=''><span>        <span class='keyword'>if</span><span> (!tm.isTokenValid()) {  </span></span></li>
    <li class='alt'><span>            log.debug(<span class='string'>"重复提交被阻止。"</span><span>);  </span></span></li>
    <li class=''><span>            setAttribute(<span class='string'>"result"</span><span>, </span><span class='string'>"不允许重复提交。"</span><span>);  </span></span></li>
    <li class='alt'><span>            <span class='keyword'>return</span><span> mapping.findForward(forward);  </span></span></li>
    <li class=''><span>        }  </span></li>
    <li class='alt'><span>        tm.saveToken();  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>        <span class='comment'>// 在后台输出请求参数</span><span>  </span></span></li>
    <li class=''><span>        <span class='keyword'>if</span><span> (SHOW_PARAMS) {  </span></span></li>
    <li class='alt'><span>            log.debug(<span class='string'>"请求参数:\n"</span><span> + getRequestParamsString());  </span></span></li>
    <li class=''><span>        }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>        <span class='comment'>// 进行参数校验</span><span>  </span></span></li>
    <li class='alt'><span>        <span class='keyword'>try</span><span> {  </span></span></li>
    <li class=''><span>            validate(form);  </span></li>
    <li class='alt'><span>            ArrayList errors = getErrors();  </span></li>
    <li class=''><span>            <span class='keyword'>if</span><span> (errors.size() &gt; </span><span class='number'>0</span><span>) {  </span></span></li>
    <li class='alt'><span>                StringBuffer buffer = <span class='keyword'>new</span><span> StringBuffer();  </span></span></li>
    <li class=''><span>                <span class='keyword'>for</span><span> (</span><span class='keyword'>int</span><span> i = </span><span class='number'>0</span><span>; i &lt; errors.size(); i++) {  </span></span></li>
    <li class='alt'><span>                    String msg = (String) errors.get(i);  </span></li>
    <li class=''><span>                    buffer.append(msg).append(<span class='string'>"\n"</span><span>);  </span></span></li>
    <li class='alt'><span>                }  </span></li>
    <li class=''><span>                String result = buffer.toString();  </span></li>
    <li class='alt'><span>                log.error(<span class='string'>"参数验证失败:"</span><span> + result);  </span></span></li>
    <li class=''><span>                setAttribute(<span class='string'>"result"</span><span>, result);  </span></span></li>
    <li class='alt'><span>                <span class='keyword'>return</span><span> mapping.findForward(forward);  </span></span></li>
    <li class=''><span>            }  </span></li>
    <li class='alt'><span>        } <span class='keyword'>catch</span><span> (Exception e) {  </span></span></li>
    <li class=''><span>            setAttribute(<span class='string'>"result"</span><span>, e.getMessage());  </span></span></li>
    <li class='alt'><span>            <span class='keyword'>return</span><span> mapping.findForward(forward);  </span></span></li>
    <li class=''><span>        }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>        <span class='comment'>// 执行子类实现的预处理</span><span>  </span></span></li>
    <li class='alt'><span>        preProcess();  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>        <span class='keyword'>try</span><span> {  </span></span></li>
    <li class=''><span>            forward = execute(form);  </span></li>
    <li class='alt'><span>        } <span class='keyword'>catch</span><span> (Exception e) {  </span></span></li>
    <li class=''><span>            reportError(e);  </span></li>
    <li class='alt'><span>            <span class='keyword'>throw</span><span> e;  </span></span></li>
    <li class=''><span>        }  </span></li>
    <li class='alt'><span>        <span class='keyword'>return</span><span> mapping.findForward(forward);  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='keyword'>private</span><span> </span><span class='keyword'>void</span><span> reportError(Exception e) {  </span></span></li>
    <li class='alt'><span>        log.warn(<span class='string'>"发送错误报告..."</span><span>);  </span></span></li>
    <li class=''><span>        ErrorReporter.report(getRequest().getRequestURI(), e);  </span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> String getRequestParamsString() {  </span></span></li>
    <li class=''><span>        NameValuePair[] params = getHelper().getAllParams();  </span></li>
    <li class='alt'><span>        StringBuffer buffer = <span class='keyword'>new</span><span> StringBuffer();  </span></span></li>
    <li class=''><span>        <span class='keyword'>for</span><span> (</span><span class='keyword'>int</span><span> i = </span><span class='number'>0</span><span>; i &lt; params.length; i++) {  </span></span></li>
    <li class='alt'><span>            NameValuePair param = params[i];  </span></li>
    <li class=''><span>            buffer.append(<span class='string'>"setRequestParam(\""</span><span>)  </span></span></li>
    <li class='alt'><span>                    .append(param.getName())  </span></li>
    <li class=''><span>                    .append(<span class='string'>"\", \""</span><span>)  </span></span></li>
    <li class='alt'><span>                    .append(param.getValue())  </span></li>
    <li class=''><span>                    .append(<span class='string'>"\");\n"</span><span>);  </span></span></li>
    <li class='alt'><span>        }  </span></li>
    <li class=''><span>        <span class='keyword'>return</span><span> buffer.toString();  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> addError(String message) {  </span></span></li>
    <li class=''><span>        ArrayList errors = getErrors();  </span></li>
    <li class='alt'><span>        errors.add(message);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 检查参数是否为空</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param paramName   request 中的参数名</span> </span></li>
    <li class=''><span><span class='comment'>     * @param failMessage 如果参数为空,则向用户显示的错误讯息</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @throws ValidationFailException 如果参数为空</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> assertExists(String paramName, String failMessage) </span><span class='keyword'>throws</span><span> ValidationFailException {  </span></span></li>
    <li class='alt'><span>        assertTrue(paramExists(paramName), failMessage);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 检查参数是否符合条件</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param expression  检查表达式</span> </span></li>
    <li class=''><span><span class='comment'>     * @param failMessage 如果不符合条件,则向用户显示的错误讯息</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @throws ValidationFailException 如果不符合条件</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> assertTrue(</span><span class='keyword'>boolean</span><span> expression, String failMessage) </span><span class='keyword'>throws</span><span> ValidationFailException {  </span></span></li>
    <li class='alt'><span>        <span class='keyword'>if</span><span> (!expression) {  </span></span></li>
    <li class=''><span>            <span class='keyword'>throw</span><span> </span><span class='keyword'>new</span><span> ValidationFailException(failMessage);  </span></span></li>
    <li class='alt'><span>        }  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 检查参数是否符合条件</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param expression  检查表达式</span> </span></li>
    <li class=''><span><span class='comment'>     * @param failMessage 如果不符合条件,则向用户显示的错误讯息</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @throws ValidationFailException 如果不符合条件</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> assertFalse(</span><span class='keyword'>boolean</span><span> expression, String failMessage) </span><span class='keyword'>throws</span><span> ValidationFailException {  </span></span></li>
    <li class='alt'><span>        assertTrue(!expression, failMessage);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 检查参数是否为空</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param value       参数值</span> </span></li>
    <li class=''><span><span class='comment'>     * @param failMessage 如果参数为空,则向用户显示的错误讯息</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @throws ValidationFailException 如果参数为空</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> assertNotEmpty(String value, String failMessage) </span><span class='keyword'>throws</span><span> ValidationFailException {  </span></span></li>
    <li class='alt'><span>        assertTrue(!StringUtil.isEmptyString(value), failMessage);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 检查数组是否为空</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param values      数组</span> </span></li>
    <li class=''><span><span class='comment'>     * @param failMessage 如果数组为空,则向用户显示的错误讯息</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @throws ValidationFailException 如果数组为空</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> assertNotEmpty(String[] values, String failMessage) </span><span class='keyword'>throws</span><span> ValidationFailException {  </span></span></li>
    <li class='alt'><span>        assertTrue(values != <span class='keyword'>null</span><span> &amp;&amp; values.length &gt; </span><span class='number'>0</span><span>, failMessage);  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> ArrayList getErrors() {  </span></span></li>
    <li class='alt'><span>        ArrayList list = (ArrayList) getRequest().getAttribute(<span class='string'>"CCIMP_REQUEST_ERRORS"</span><span>);  </span></span></li>
    <li class=''><span>        <span class='keyword'>if</span><span> (list == </span><span class='keyword'>null</span><span>) {  </span></span></li>
    <li class='alt'><span>            list = <span class='keyword'>new</span><span> ArrayList();  </span></span></li>
    <li class=''><span>            getRequest().setAttribute(<span class='string'>"CCIMP_REQUEST_ERRORS"</span><span>, list);  </span></span></li>
    <li class='alt'><span>        }  </span></li>
    <li class=''><span>        <span class='keyword'>return</span><span> list;  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>/**</span> </span></li>
    <li class=''><span><span class='comment'>     * 获得一个 AccessControl 实例</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @return 一个 AccessControl 实例</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> AccessControl getAccessControl() {  </span></span></li>
    <li class='alt'><span>        <span class='keyword'>return</span><span> getHelper().getAccessControl();  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 获得请求对象</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @return 请求对象</span> </span></li>
    <li class=''><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> HttpServletRequest getRequest() {  </span></span></li>
    <li class=''><span>        <span class='keyword'>return</span><span> getHelper().getRequest();  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>/**</span> </span></li>
    <li class=''><span><span class='comment'>     * 获得回应对象</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @return 回应对象</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> HttpServletResponse getResponse() {  </span></span></li>
    <li class='alt'><span>        <span class='keyword'>return</span><span> getHelper().getResponse();  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 将对象放入 request</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param name  名称</span> </span></li>
    <li class=''><span><span class='comment'>     * @param value 对象</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> setAttribute(String name, Object value) {  </span></span></li>
    <li class='alt'><span>        getRequest().setAttribute(name, value);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 将数值放入 request</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param name 名称</span> </span></li>
    <li class=''><span><span class='comment'>     * @param num  数值</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> setAttribute(String name, </span><span class='keyword'>int</span><span> num) {  </span></span></li>
    <li class='alt'><span>        setAttribute(name, <span class='keyword'>new</span><span> Integer(num));  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 将 boolean 值放入 request</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param name 名称</span> </span></li>
    <li class=''><span><span class='comment'>     * @param b    boolean 值</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> setAttribute(String name, </span><span class='keyword'>boolean</span><span> b) {  </span></span></li>
    <li class='alt'><span>        setAttribute(name, Boolean.valueOf(b));  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 获得 request 中的值</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param name 名称</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @return request 中的值</span> </span></li>
    <li class=''><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> Object getAttribute(String name) {  </span></span></li>
    <li class=''><span>        <span class='keyword'>return</span><span> getRequest().getAttribute(name);  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>// 获得请求参数</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> String getParam(String name) {  </span></span></li>
    <li class='alt'><span>        <span class='keyword'>return</span><span> getHelper().getParam(name);  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>// 获得请求参数</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> String getParamFromRequestAndSession(String name) {  </span></span></li>
    <li class=''><span>        String value = getHelper().getParam(name);  </span></li>
    <li class='alt'><span>        <span class='keyword'>if</span><span> (StringUtil.isEmptyString(value)) {  </span></span></li>
    <li class=''><span>            value = StringUtil.replaceNull(getSessionAttributeOnce(name));  </span></li>
    <li class='alt'><span>        }  </span></li>
    <li class=''><span>        <span class='keyword'>return</span><span> value;  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>// 获得请求参数</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> String getParam(String name, Object defaultValue) {  </span></span></li>
    <li class='alt'><span>        <span class='keyword'>return</span><span> getHelper().getParam(name, StringUtil.replaceNull(defaultValue));  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>// 获得请求参数</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> String[] getParamValues(String name) {  </span></span></li>
    <li class=''><span>        <span class='keyword'>return</span><span> getHelper().getParamValues(name);  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> String getSessionString(String name) {  </span></span></li>
    <li class=''><span>        <span class='keyword'>return</span><span> getHelper().getSessionString(name);  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> String[] getParamNames() {  </span></span></li>
    <li class=''><span>        ArrayList nameArr = <span class='keyword'>new</span><span> ArrayList();  </span></span></li>
    <li class='alt'><span>        Enumeration names = getRequest().getParameterNames();  </span></li>
    <li class=''><span>        <span class='keyword'>while</span><span> (names.hasMoreElements()) {  </span></span></li>
    <li class='alt'><span>            nameArr.add(names.nextElement());  </span></li>
    <li class=''><span>        }  </span></li>
    <li class='alt'><span>        <span class='keyword'>return</span><span> (String[]) nameArr.toArray(</span><span class='keyword'>new</span><span> String[nameArr.size()]);  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 设置处理结果信息</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param message 处理结果信息(如“记录添加成功!”等,用于显示在页面上)</span> </span></li>
    <li class=''><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> setActionMessage(String message) {  </span></span></li>
    <li class=''><span>        setSessionAttribute(<span class='string'>"ccimp_message"</span><span>, </span><span class='keyword'>new</span><span> Message(Message.INFO, message));  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>/**</span> </span></li>
    <li class=''><span><span class='comment'>     * 设置处理结果信息</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @param message 处理结果信息(如“记录添加成功!”等,用于显示在页面上)</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> setActionMessage(Message message) {  </span></span></li>
    <li class='alt'><span>        setSessionAttribute(<span class='string'>"ccimp_message"</span><span>, message);  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 设置处理结果错误信息</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param message 处理结果错误信息(如“记录添加失败:ID 重复”等,用于显示在页面上)</span> </span></li>
    <li class=''><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> setActionErrorMessage(String message) {  </span></span></li>
    <li class=''><span>        setSessionAttribute(<span class='string'>"ccimp_message"</span><span>, </span><span class='keyword'>new</span><span> Message(Message.ERROR, message));  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>/**</span> </span></li>
    <li class=''><span><span class='comment'>     * 设置是否进行访问权限的检查。单元测试中应将其设置为false。</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @param validation 是否进行访问权限的检查</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>public</span><span> </span><span class='keyword'>void</span><span> setAccessValidation(</span><span class='keyword'>boolean</span><span> validation) {  </span></span></li>
    <li class='alt'><span>        getHelper().setAccessValidation(validation);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='keyword'>public</span><span> </span><span class='keyword'>void</span><span> setHelper(PageHelper h) {  </span></span></li>
    <li class='alt'><span>        helperContainer.set(h);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> PageHelper getHelper() {  </span></span></li>
    <li class='alt'><span>        <span class='keyword'>return</span><span> (PageHelper) helperContainer.get();  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 执行请求</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param form 表单</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @return 要跳转的 forward 名称</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @throws Exception 如果执行失败</span> </span></li>
    <li class=''><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>public</span><span> </span><span class='keyword'>abstract</span><span> String execute(ActionForm form) </span><span class='keyword'>throws</span><span> Exception;  </span></span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>/**</span> </span></li>
    <li class=''><span><span class='comment'>     * 执行请求之前的预处理</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> preProcess() {  </span></span></li>
    <li class='alt'><span>        <span class='comment'>// 给子类使用</span><span>  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 校验参数</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param form 表单</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @throws Exception 如果执行校验失败</span> </span></li>
    <li class=''><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> validate(ActionForm form) </span><span class='keyword'>throws</span><span> Exception {  </span></span></li>
    <li class=''><span>        <span class='comment'>// 给子类使用</span><span>  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>/**</span> </span></li>
    <li class=''><span><span class='comment'>     * 写业务日志</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @param action  动作</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param object  对象</span> </span></li>
    <li class=''><span><span class='comment'>     * @param message 日志信息</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> log(String action, String object, String message) {  </span></span></li>
    <li class='alt'><span>        getHelper().writeLog(action, object, message);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 写业务日志</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param action  动作</span> </span></li>
    <li class=''><span><span class='comment'>     * @param message 日志信息</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> log(String action, String message) {  </span></span></li>
    <li class='alt'><span>        log(action, <span class='string'>""</span><span>, message);  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 设置 session 属性</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param name  属性名称</span> </span></li>
    <li class=''><span><span class='comment'>     * @param value 属性值</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> </span><span class='keyword'>void</span><span> setSessionAttribute(String name, Object value) {  </span></span></li>
    <li class='alt'><span>        getRequest().getSession().setAttribute(name, value);  </span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 获得 session 属性</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param name 属性名</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @return 属性值</span> </span></li>
    <li class=''><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class='alt'><span>    <span class='keyword'>protected</span><span> Object getSessionAttribute(String name) {  </span></span></li>
    <li class=''><span>        <span class='keyword'>return</span><span> getRequest().getSession().getAttribute(name);  </span></span></li>
    <li class='alt'><span>    }  </span></li>
    <li class=''><span>  </span></li>
    <li class='alt'><span>    <span class='comment'>/**</span> </span></li>
    <li class=''><span><span class='comment'>     * 获得 session 属性,只取一次</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @param name 属性名</span> </span></li>
    <li class='alt'><span><span class='comment'>     *</span> </span></li>
    <li class=''><span><span class='comment'>     * @return 属性值</span> </span></li>
    <li class='alt'><span><span class='comment'>     */</span><span>  </span></span></li>
    <li class=''><span>    <span class='keyword'>protected</span><span> Object getSessionAttributeOnce(String name) {  </span></span></li>
    <li class='alt'><span>        Object value = getRequest().getSession().getAttribute(name);  </span></li>
    <li class=''><span>        getRequest().getSession().removeAttribute(name);  </span></li>
    <li class='alt'><span>        <span class='keyword'>return</span><span> value;  </span></span></li>
    <li class=''><span>    }  </span></li>
    <li class='alt'><span>  </span></li>
    <li class=''><span>    <span class='comment'>/**</span> </span></li>
    <li class='alt'><span><span class='comment'>     * 检查当前用户是否拥有指定操作的权限</span> </span></li>
    <li class=''><span><span class='comment'>     *</span> </span></li>
    <li class='alt'><span><span class='comment'>     * @param</span></span></li></ol></div>
7 楼 gs.liutong 2007-07-17  
这样做是不是让MVC结构更模糊了?Action应该是显示层的组间,返回值forward定义了要将结过呈现出来的页面。
由后台Bean来决定forward的值,增加了显示层和后台模型层的耦合。这样会影响到系统组间的可重用性。对项目的成本和效率都会造成一定影响吧。
6 楼 dongguoh 2007-07-17  
ActionContext不是Struts当中的类,
这是一个自定义的类,这个类用来保存一些错误的信息
初始化request和response

你所说的在Bean中的业务方法是增加啦不少的代码~
至于如何调用action的一些方法,这里没有仔细想过
你说到的这几个问题很好,点醒啦我
5 楼 flxi78 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的代码会比较凌乱。
4 楼 dongguoh 2007-07-16  
flxi78 写道
要想通用太难了。。就我个人在开发中碰到的问题,动态方法,include,download等action的功能要整合在一起就很麻烦。至于在dispatchAction下,由于form的invalidate方法出错后,返回的input页面如何解决


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

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

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

由于关联的代码太多,我就只发这个最主要的上来
3 楼 flxi78 2007-07-16  
要想通用太难了。。就我个人在开发中碰到的问题,动态方法,include,download等action的功能要整合在一起就很麻烦。至于在dispatchAction下,由于form的invalidate方法出错后,返回的input页面如何解决
2 楼 giscat 2007-07-16  

Map model = JspUtil.getRequestModel(request);
  //把request参数塞到map里
    ORM.insert(tableName,model);
    //ORM.update(tableName,model);
     //orm 是diy的ORM小工具
1 楼 stone 2007-07-16  
你还是看看dispathAction和dynamicFormBean吧

相关推荐

    一个Action对应多个类实例。

    在Struts框架中,"一个Action对应多个类实例"的概念是设计模式的一种体现,它涉及到MVC(模型-视图-控制器)架构的实现。Struts是一个基于Java Servlet和JSP的开源框架,用于构建企业级Web应用程序。在这个框架中,...

    Spring in Action 使用Maven 构建Spring 工程

    Maven是一个流行的项目管理和综合工具,它通过提供一套标准化的构建过程,简化了Java项目的构建、依赖管理和部署。在Spring开发中,Maven扮演着至关重要的角色,它帮助开发者管理各种库依赖,使得Spring应用程序的...

    YII 通用CURD外部Action 适合单表

    标题 "YII 通用CURD外部Action 适合单表" 提到的是在Yii框架中创建一个通用的CURD(创建、读取、更新、删除)操作的外部Action,这种Action适用于处理单个数据表的常见数据库操作。在Yii框架中,Action是Controller...

    构建一种通用的领域语言,使业务层能够实现灵活的配置

    总结一下,构建通用领域语言的关键在于识别和封装业务中的原子操作,并提供一个框架让业务层能够自由地组合这些操作。在C++中,我们可以利用面向对象和设计模式来实现这一目标。在给定的示例中,我们创建了一个简单...

    自己构建Struts框架的基本思路

    在本文中,我们将探讨如何自己构建一个基于Struts2的简单框架,了解其基本思路和主要步骤。 首先,Struts2是Apache Jakarta项目中的一个组件,它是Struts1和WebWork框架的合并产物。Struts2的核心是基于拦截器的...

    ssh三大框架通用配置

    SSH是Java Web开发中的一个流行组合,由Spring、Struts和Hibernate三个开源框架组成。这三个框架协同工作,为开发者提供了一种高效、灵活且可扩展的解决方案,用于构建企业级应用。下面我们将深入探讨SSH框架的通用...

    通用web层action代码

    通用web层action,完美解决shiro注解权限控制,读取子类泛型

    一个通用积分的网站,开发了一半

    标题中的“一个通用积分的网站,开发了一半”意味着这个项目是一个在线积分管理系统,它可能被设计用来跟踪和管理用户在各种活动或购买中的积分积累。这个系统在开发过程中已经完成了部分功能,但还未全部完成,暗示...

    用MockStrutsTestCase测试action测试类

    在Java Web开发中,Struts框架是一个非常流行的MVC(模型-视图-控制器)架构,用于构建可维护和可扩展的Web应用程序。在Struts框架中,Action类是核心组件,负责处理用户请求并调用业务逻辑。为了确保Action类的正确...

    ActionServlet demo

    【ActionServlet demo】是一个基于Java和Servlet技术的示例项目,它主要展示了如何在Web应用程序中使用Servlet来处理用户请求并驱动业务逻辑。这个项目可能与Struts 1.3框架相结合,Struts是一个广泛使用的MVC(模型...

    Struts2--3.Action及相关-1

    每个命名空间可以看作是应用程序的一个独立部分,有自己的Action和视图。 综上所述,这些文件详细阐述了Struts2中Action的使用和相关配置,包括Action的创建、执行方法的指定、路径配置、通配符映射、参数处理、...

    封装通用的Spring3+Struts2+IBatis的CRUD

    **Struts2框架** 是一个基于MVC设计模式的Web应用框架,它允许开发者通过Action类来处理用户请求,并使用配置文件定义Action与结果视图之间的映射。Struts2与Spring的集成使得我们可以轻松地利用Spring的DI特性来...

    Ruby-使用Ruby和GitHubAPI构建Action的快速入门配方

    使用Ruby和GitHub API构建Action的快速入门配方

    基于struts2、spring、hibernate构建一个网上投票系统-毕业论文.doc

    《基于Struts2、Spring、Hibernate构建一个网上投票系统》 ...对于初学者而言,这是一个很好的实践案例,有助于理解Web应用的开发流程和框架之间的协作。而对于有经验的开发者,它也能提供一些新的思考角度和优化方案。

    SSM 实现通用分页

    在实际应用中,分页通常会涉及到一个通用的Page类,该类包含当前页、总页数、每页条数以及数据列表等属性。在Service层,我们可以创建一个通用的分页方法,接受页码和每页大小作为参数,然后调用MyBatis的Mapper进行...

    moke测试struts的action

    如果这是测试代码,那么可能包含了一个模拟用户行为的测试类,用于测试Struts Action的功能。如果是配置文件,可能是Struts的配置文件(struts-config.xml或struts2的struts.xml),包含了Action的定义及其与视图和...

    EXTJS4.0视频教程配套代码包含action类

    5. 远程操作(Operation):封装了一个具体的请求,包括请求类型、URL、参数和回调函数。 在提供的压缩包文件中,可能包含了与视频教程同步的示例代码,如控制器(Controller)、视图(View)、模型(Model)、存储...

    Struts 2使用注解配置Action

    4. `@IncludeResult`: 如果Action需要引用一个通用的结果页面,可以使用`@IncludeResult`注解。这样可以避免在每个Action中重复定义相同的结果。 5. `@ParentPackage`: 用于指定Action继承自哪个Struts 2配置包,...

Global site tag (gtag.js) - Google Analytics