Struts2核心配置 struts-default包和default-stack拦截器链

    1. <package name="struts-default">  
    2.    . . .    
    3.    <interceptors>  
    4.       <interceptor  name="execAndWait" class="ExecuteAndWaitInterceptor"/>  
    5.       <interceptor  name="exception" class="ExceptionMappingInterceptor"/>  
    6.       <interceptor name="fileUpload" class="FileUploadInterceptor"/>         
    7.       <interceptor name="i18n" class="I18nInterceptor"/>                           
    8.       <interceptor name="logger" class="LoggingInterceptor"/>                    
    9.       <interceptor name="modelDriven" class="ModelDrivenInterceptor"/>      
    10.       <interceptor name="scoped-modelDriven" class= . . ./>      
    11.       <interceptor name="params" class="ParametersInterceptor"/>              
    12.       <interceptor name="prepare" class="PrepareInterceptor"/>                  
    13.       <interceptor name="static-params" class=. . ./>             
    14.       <interceptor  name="servlet-config" class="ServletConfigInterceptor"/>  
    15.       <interceptor name="sessionAutowiring"                                           
    16.                                class="SessionContextAutowiringInterceptor"/>      
    17.       <interceptor name="timer" class="TimerInterceptor"/>                    
    18.       <interceptor name="token" class="TokenInterceptor"/>                    
    19.       <interceptor name="token-session" class= . . . />           
    20.       <interceptor name="validation" class= . . . />          
    21.       <interceptor  name="workflow" class="DefaultWorkflowInterceptor"/>  
    22.           . . .  
    23.       <interceptor-stack name="defaultStack">  
    24.          <interceptor-ref name="exception"/>         
    25.          <interceptor-ref name="alias"/>               
    26.          <interceptor-ref name="servlet-config"/>  
    27.          <interceptor-ref name="prepare"/>            
    28.          <interceptor-ref name="i18n"/>                
    29.          <interceptor-ref name="chain"/>               
    30.          <interceptor-ref name="debugging"/>         
    31.          <interceptor-ref name="profiling"/>         
    32.          <interceptor-ref name="scoped-modelDriven"/>                        
    33.          <interceptor-ref name="modelDriven"/>                             
    34.          <interceptor-ref name="fileUpload"/>                                 
    35.          <interceptor-ref name="checkbox"/>                                 
    36.          <interceptor-ref name="static-params"/>                             
    37.          <interceptor-ref name="params">                                      
    38.             <param name="excludeParams">dojo/..*</param>  
    39.          </interceptor-ref>                                                   
    40.          <interceptor-ref name="conversionError"/>                            
    41.          <interceptor-ref name="validation">                                  
    42.               <param name="excludeMethods">input,back,cancel,browse</param>  
    43.          </interceptor-ref>                                                   
    44.          <interceptor-ref name="workflow">                                    
    45.              <param name="excludeMethods">input,back,cancel,browse</param>  
    46.          </interceptor-ref>                                                   
    47.       </interceptor-stack>  
    48.    </interceptors>  
    49.    <default-interceptor-ref name="defaultStack"/>  
    50. </package> 

应用:

如何使用struts2拦截器,或者自定义拦截器。特别注意,在使用拦截器的时候,在Action里面必须最后一定要引用struts2自带的拦截器缺省堆栈defaultStack,如下(这里我是引用了struts2自带的checkbox拦截器):

<interceptor-ref name="checkbox">
<param name="uncheckedValue">0</param>
</interceptor-ref>
<interceptor-ref name="defaultStack"/>
(必须加,否则出错)

posted @ 2013-06-03 19:45  小泥巴1024  阅读(556)  评论(0编辑  收藏  举报