interceptor-stack跟interceptor-ref的区别

interceptor-stack是一堆拦截器组成的一个拦截器栈。也可以当拦截器使用。

interceptor-ref是指定某个action使用哪一个拦截器,可以是一个interceptor,也可以是一个interceptor-stack。

下边是网上找的一个配置说明

  1. <package name="struts2" extends="json-default" namespace="/">  
  2.   
  3.         <interceptors>  
  4.             <!-- 定义权限拦截器 -->  
  5.             <interceptor name="permission"  
  6.                 class="com.yinlu.rm.web.PermissionInterceptor" />  
  7.             <!-- 定义拦截器栈,所谓拦截器栈,是指由一个或多个拦截器组成 -->  
  8.             <interceptor-stack name="permissionStack">  
  9.                 <!-- struts2 提供的拦截器栈,包含了struts2的很多核心拦截器 -->  
  10.                 <interceptor-ref name="defaultStack" />  
  11.                 <!-- 自己定义的放在最后面,struts2定义的放在前面 -->  
  12.                 <interceptor-ref name="permission" />  
  13.             </interceptor-stack>  
  14.         </interceptors>  
  15.   
  16.         <!-- 为此包下的所有action应用拦截器 -->  
  17.         <default-interceptor-ref name="permissionStack" />  
  18.   <!--
    1. 全局result(global-results)
      有很多时候一个<result>可供很多<action>使用,这时可以使用<global-results>标签来定义全局的<result>l。
    2. 执行顺序:当一个Action返回的String没有相应的<result>与之对应,Struts2就会查找全局的<result>。
    -->
  19.         <global-results>  
  20.             <result name="message">/message.jsp</result>  
  21.         </global-results>  
  22. <action name="person" class="personAction">  
  23.             <result type="json">  
  24.                 <param name="excludeProperties">.*hibernateLazyInitializer</param>  
  25.                 <param name="includeProperties">message,success</param>  
  26.             </result>  
  27. </action>  
  28. </package

<?xml version="1.0" encoding="UTF-8" ?> <!-- /* * $Id: struts-plugin.xml 722219 2008-12-01 20:41:26Z musachy $ * * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ --> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN" "http://struts.apache.org/dtds/struts-2.5.dtd"> <struts> <bean class="com.inc.sbu.view.FreeMarkerPageFilter" static="true" optional="true"/> <constant name="struts.ognl.allowStaticMethodAccess" value="true" /> <constant name="struts.convention.relative.result.types" value="freemarker,dispatcher"/> <constant name="struts.convention.action.mapAllMatches" value="true"/> <constant name="struts.convention.package.locators" value="web,action" /> <constant name="struts.convention.default.parent.package" value="yk-default"/> <constant name="struts.convention.result.path" value="/pages"/> <constant name="struts.convention.result.flatLayout" value="true"/> <constant name="struts.i18n.encoding" value="gbk" /> <constant name="struts.i18n.reload" value="false" /> <constant name="struts.devMode" value="false" /> <constant name="struts.serve.static.browserCache" value="false"/> <constant name="struts.configuration.xml.reload" value="false" /> <constant name="struts.custom.i18n.resources" value="globalMessages" /> <constant name="struts.freemarker.manager.classname" value="customFreemarkerManager" /> <constant name="struts.multipart.saveDir" value="/tmp"/> <constant name="struts.multipart.maxSize" value="1000000000" /> <constant name="struts.ui.theme" value="simple"/> <constant name="struts.action.extension" value="xhtml,,json" /> <constant name="struts.enable.DynamicMethodInvocation" value="true"/> <package name="yk-default" extends="struts-default"> <result-types> <result-type name="jasper" class="org.apache.struts2.views.jasperreports.JasperReportsResult"/> <result-type name="json" class="org.apache.struts2.json.JSONResult"/> </result-types> <interceptors> <interceptor class="com.inc.sbu.struts.AuctionInterceptor" name="auctionInterceptor"/> <interceptor class="com.inc.sbu.struts.TokenInterceptor" name="incTokenInterceptor"/> <interceptor class="com.inc.sbu.struts.WorkFlowInterceptor" name="incFlowInterceptor"/> <interceptor class="com.inc.sbu.util.FileUploadInterceptor" name="fileUploadInterceptor"/> <interceptor class="com.inc.sbu.struts.ClewInterceptor" name="clewInterceptor"/> <interceptor-stack name="bidStack"> <interceptor-ref name="exception"/> <interceptor-ref name="alias"/> <interceptor-ref name="servletConfig"/> <interceptor-ref name="prepare"/> <interceptor-ref name="profiling"/> <interceptor-ref name="staticParams"/> <interceptor-ref name="actionMappingParams"/> <interceptor-ref name="params"> <param name="excludeParams">dojo\..*,^struts\..*</param> </interceptor-ref> <interceptor-ref name="conversionError"/> <interceptor-ref name="auctionInterceptor"/> </interceptor-stack> <interceptor-stack name="subStack"> <interceptor-ref name="exception"/> <interceptor-ref name="alias"/> <interceptor-ref name="servletConfig"/> <interceptor-ref name="i18n"/> <interceptor-ref name="prepare"/> <interceptor-ref name="chain"/> <interceptor-ref name="profiling"/> <interceptor-ref name="scopedModelDriven"/> <interceptor-ref name="fileUploadInterceptor"/> <interceptor-ref name="fileUpload"/> <interceptor-ref name="checkbox"/> <interceptor-ref name="staticParams"/> <interceptor-ref name="actionMappingParams"/> <interceptor-ref name="params"> <param name="excludeParams">dojo\..*,^struts\..*</param> </interceptor-ref> <interceptor-ref name="conversionError"/> <interceptor-ref name="validation"> <param name="excludeMethods">input,inputxy,back,cancel,browse</param> </interceptor-ref> <interceptor-ref name="clewInterceptor"> <param name="excludeMethods">login,loginManager,logout,index</param> </interceptor-ref> <interceptor-ref name="incTokenInterceptor"/> </interceptor-stack> </interceptors> <default-interceptor-ref name="subStack"/> <global-results> <result name="invalid.token">/pages/error/repeat-submit.jsp</result> <result name="clew" type="dispatcher">/pages/clew.jsp</result> <result name="manage-clew" type="dispatcher">/pages/manage-clew.jsp</result> <result name="auction-clew" type="dispatcher">/pages/auction-clew.jsp</result> <result name="syserror" type="dispatcher">/pages/error.jsp</result> <result name="validerror" type="dispatcher">/pages/error.jsp</result> <result name="frontpurviewerror" type="dispatcher">/pages/error/frontpurviewerror.jsp</result> <result name="frontloginerror" type="dispatcher">/pages/error/frontpurviewerror.jsp</result> <result name="fronterror" type="dispatcher">/pages/error/frontticketerror.jsp</result> <result name="filenotfound" type="dispatcher">/pages/error/filenotfound.jsp</result> <result name="login" type="redirect">/login</result> <result name="adminLogin" type="dispatcher">/login.jsp</result> <result name="login" type="redirect">/login</result> <result name="entran" type="redirect">/entran</result> <!-- <result name="adminLogin" type="dispatcher">/login.jsp</result> --> <result name="auctionAdminError" type="redirect">/auction/adminLogin</result> <result name="auctionActorError" type="redirect">/auction/login</result> </global-results> </package> <!-- Overwrite Convention --> </struts> 我现在需要重写fileUpload,即不再使用fileUpload的拦截器,需要怎么配置
最新发布
08-01
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值