Struts2--struts.xml详解

通常,struts.xml文件都会继承一个struts-default.xml文件通过一些基本的拦截器来提供一些基本的配置设置之类的。

配置例:

 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE struts PUBLIC
 3     "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
 4     "http://struts.apache.org/dtds/struts-2.5.dtd">
 5 
 6 <struts>
 7     <!-- 开启debug模式,会自动加载配置文件等等,不用每次更改了配置文件就去重新启动下服务器 -->
 8     <constant name="struts.devMode" value="true" />
 9     
10     <package name="test" namespace="/student" extends="struts-default">
11         <action name="show" method="showStu" class="com.fuwh.demo.Show">
12             <result name="success">hello.jsp</result>
13            
14         </action>
15         
16     </package>
17 
18 </struts>

struts-default.xml的详细内容

  1 <?xml version="1.0" encoding="UTF-8" ?>
  2 <!--
  3 /*
  4  * $Id$
  5  *
  6  * Licensed to the Apache Software Foundation (ASF) under one
  7  * or more contributor license agreements.  See the NOTICE file
  8  * distributed with this work for additional information
  9  * regarding copyright ownership.  The ASF licenses this file
 10  * to you under the Apache License, Version 2.0 (the
 11  * "License"); you may not use this file except in compliance
 12  * with the License.  You may obtain a copy of the License at
 13  *
 14  *  http://www.apache.org/licenses/LICENSE-2.0
 15  *
 16  * Unless required by applicable law or agreed to in writing,
 17  * software distributed under the License is distributed on an
 18  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 19  * KIND, either express or implied.  See the License for the
 20  * specific language governing permissions and limitations
 21  * under the License.
 22  */
 23 -->
 24 
 25 <!--
 26     When declaring beans in this file you must either use name="struts" or don't name the bean at all.
 27 
 28     The name="struts" must be used when alias was defined in {@link org.apache.struts2.config.DefaultBeanSelectionProvider} -
 29     it is then the default bean's name and {@link org.apache.struts2.config.DefaultBeanSelectionProvider} links name "struts"
 30     with "default" (aliasing it)
 31 
 32     If name won't be defined then the "default" value will be used {@link com.opensymphony.xwork2.inject.Container#DEFAULT_NAME}
 33     and {@link com.opensymphony.xwork2.inject.Inject}
 34 -->
 35 <!DOCTYPE struts PUBLIC
 36     "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
 37     "http://struts.apache.org/dtds/struts-2.5.dtd">
 38 
 39 <struts>
 40 
 41     <constant name="struts.excludedClasses"
 42               value="
 43                 java.lang.Object,
 44                 java.lang.Runtime,
 45                 java.lang.System,
 46                 java.lang.Class,
 47                 java.lang.ClassLoader,
 48                 java.lang.Shutdown,
 49                 java.lang.ProcessBuilder,
 50                 ognl.OgnlContext,
 51                 ognl.ClassResolver,
 52                 ognl.TypeConverter,
 53                 ognl.MemberAccess,
 54                 ognl.DefaultMemberAccess,
 55                 com.opensymphony.xwork2.ognl.SecurityMemberAccess,
 56                 com.opensymphony.xwork2.ActionContext" />
 57 
 58     <!-- this must be valid regex, each '.' in package name must be escaped! -->
 59     <!-- it's more flexible but slower than simple string comparison -->
 60     <!-- constant name="struts.excludedPackageNamePatterns" value="^java\.lang\..*,^ognl.*,^(?!javax\.servlet\..+)(javax\..+)" / -->
 61 
 62     <!-- this is simpler version of the above used with string comparison -->
 63     <constant name="struts.excludedPackageNames" value="java.lang.,ognl,javax" />
 64 
 65     <bean class="com.opensymphony.xwork2.ObjectFactory" name="struts"/>
 66     <bean type="com.opensymphony.xwork2.factory.ResultFactory" name="struts" class="org.apache.struts2.factory.StrutsResultFactory" />
 67     <bean type="com.opensymphony.xwork2.factory.ActionFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultActionFactory" />
 68     <bean type="com.opensymphony.xwork2.factory.ConverterFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultConverterFactory" />
 69     <bean type="com.opensymphony.xwork2.factory.InterceptorFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultInterceptorFactory" />
 70     <bean type="com.opensymphony.xwork2.factory.ValidatorFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultValidatorFactory" />
 71     <bean type="com.opensymphony.xwork2.factory.UnknownHandlerFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultUnknownHandlerFactory" />
 72 
 73     <bean type="com.opensymphony.xwork2.FileManager" class="com.opensymphony.xwork2.util.fs.DefaultFileManager" name="system" scope="singleton"/>
 74     <bean type="com.opensymphony.xwork2.FileManagerFactory" class="com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory" name="struts" scope="singleton"/>
 75 
 76     <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="struts" class="org.apache.struts2.factory.StrutsActionProxyFactory"/>
 77     <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="prefix" class="org.apache.struts2.factory.PrefixBasedActionProxyFactory"/>
 78 
 79     <bean type="com.opensymphony.xwork2.conversion.ObjectTypeDeterminer" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer"/>
 80 
 81     <bean type="com.opensymphony.xwork2.util.PatternMatcher" name="struts" class="com.opensymphony.xwork2.util.WildcardHelper" />
 82     <bean type="com.opensymphony.xwork2.util.PatternMatcher" name="namedVariable" class="com.opensymphony.xwork2.util.NamedVariablePatternMatcher"/>
 83     <bean type="com.opensymphony.xwork2.util.PatternMatcher" name="regex" class="org.apache.struts2.util.RegexPatternMatcher"/>
 84 
 85     <bean type="org.apache.struts2.util.ContentTypeMatcher" name="struts" class="org.apache.struts2.util.DefaultContentTypeMatcher"/>
 86 
 87     <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="struts" class="org.apache.struts2.dispatcher.mapper.DefaultActionMapper" />
 88     <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="composite" class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />
 89     <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="restful" class="org.apache.struts2.dispatcher.mapper.RestfulActionMapper" />
 90     <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="restful2" class="org.apache.struts2.dispatcher.mapper.Restful2ActionMapper" />
 91 
 92     <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta" class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" scope="prototype"/>
 93     <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta-stream" class="org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest" scope="prototype"/>
 94 
 95     <bean type="org.apache.struts2.views.TagLibraryDirectiveProvider" name="s" class="org.apache.struts2.views.DefaultTagLibrary" />
 96     <bean type="org.apache.struts2.views.TagLibraryModelProvider" name="s" class="org.apache.struts2.views.DefaultTagLibrary" />
 97 
 98     <bean class="org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader" />
 99     <bean class="org.apache.struts2.views.freemarker.FreemarkerManager" name="struts" />
100     <bean class="org.apache.struts2.views.velocity.VelocityManager" name="struts" optional="true" />
101 
102     <bean class="org.apache.struts2.components.template.TemplateEngineManager" />
103     <bean type="org.apache.struts2.components.template.TemplateEngine" name="ftl" class="org.apache.struts2.components.template.FreemarkerTemplateEngine" />
104     <bean type="org.apache.struts2.components.template.TemplateEngine" name="vm" class="org.apache.struts2.components.template.VelocityTemplateEngine" />
105     <bean type="org.apache.struts2.components.template.TemplateEngine" name="jsp" class="org.apache.struts2.components.template.JspTemplateEngine" />
106 
107     <bean type="com.opensymphony.xwork2.conversion.impl.XWorkConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.XWorkConverter" />
108 
109     <bean type="com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultConversionPropertiesProcessor" />
110     <bean type="com.opensymphony.xwork2.conversion.ConversionFileProcessor" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultConversionFileProcessor" />
111     <bean type="com.opensymphony.xwork2.conversion.ConversionAnnotationProcessor" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor" />
112     <bean type="com.opensymphony.xwork2.conversion.TypeConverterCreator" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultTypeConverterCreator" />
113     <bean type="com.opensymphony.xwork2.conversion.TypeConverterHolder" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultTypeConverterHolder" />
114 
115     <bean class="com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter" />
116 
117     <bean type="com.opensymphony.xwork2.conversion.impl.CollectionConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.CollectionConverter" scope="singleton"/>
118     <bean type="com.opensymphony.xwork2.conversion.impl.ArrayConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.ArrayConverter" scope="singleton"/>
119     <bean type="com.opensymphony.xwork2.conversion.impl.DateConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.DateConverter" scope="singleton"/>
120     <bean type="com.opensymphony.xwork2.conversion.impl.NumberConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.NumberConverter" scope="singleton"/>
121     <bean type="com.opensymphony.xwork2.conversion.impl.StringConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.StringConverter" scope="singleton"/>
122 
123     <bean type="com.opensymphony.xwork2.TextProvider" name="struts" class="com.opensymphony.xwork2.TextProviderSupport" scope="prototype" />
124     <bean type="com.opensymphony.xwork2.LocaleProvider" name="struts" class="com.opensymphony.xwork2.DefaultLocaleProvider" scope="singleton" />
125 
126     <bean type="org.apache.struts2.components.UrlRenderer" name="struts" class="org.apache.struts2.components.ServletUrlRenderer"/>
127     <bean type="org.apache.struts2.views.util.UrlHelper" name="struts" class="org.apache.struts2.views.util.DefaultUrlHelper"/>
128 
129     <bean type="com.opensymphony.xwork2.util.ValueStackFactory" name="struts" class="com.opensymphony.xwork2.ognl.OgnlValueStackFactory" />
130     <bean type="com.opensymphony.xwork2.util.reflection.ReflectionProvider" name="struts" class="com.opensymphony.xwork2.ognl.OgnlReflectionProvider" />
131     <bean type="com.opensymphony.xwork2.util.reflection.ReflectionContextFactory" name="struts" class="com.opensymphony.xwork2.ognl.OgnlReflectionContextFactory" />
132 
133     <bean type="com.opensymphony.xwork2.TextProvider" name="system" class="com.opensymphony.xwork2.DefaultTextProvider" />
134     <bean type="com.opensymphony.xwork2.conversion.NullHandler" name="java.lang.Object" class="com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler" />
135 
136     <bean type="com.opensymphony.xwork2.validator.ActionValidatorManager" name="struts" class="com.opensymphony.xwork2.validator.AnnotationActionValidatorManager" />
137     <bean type="com.opensymphony.xwork2.validator.ActionValidatorManager" name="no-annotations" class="com.opensymphony.xwork2.validator.DefaultActionValidatorManager" />
138 
139     <bean type="com.opensymphony.xwork2.validator.ValidatorFactory" class="com.opensymphony.xwork2.validator.DefaultValidatorFactory"/>
140     <bean type="com.opensymphony.xwork2.validator.ValidatorFileParser" class="com.opensymphony.xwork2.validator.DefaultValidatorFileParser" />
141 
142     <bean class="com.opensymphony.xwork2.ognl.OgnlUtil" />
143 
144     <bean type="com.opensymphony.xwork2.util.TextParser" name="struts" class="com.opensymphony.xwork2.util.OgnlTextParser" scope="singleton"/>
145 
146     <bean type="ognl.PropertyAccessor" name="com.opensymphony.xwork2.util.CompoundRoot" class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor" />
147     <bean type="ognl.PropertyAccessor" name="java.lang.Object" class="com.opensymphony.xwork2.ognl.accessor.ObjectAccessor" />
148     <bean type="ognl.PropertyAccessor" name="java.util.Iterator" class="com.opensymphony.xwork2.ognl.accessor.XWorkIteratorPropertyAccessor" />
149     <bean type="ognl.PropertyAccessor" name="java.util.Enumeration" class="com.opensymphony.xwork2.ognl.accessor.XWorkEnumerationAccessor" />
150     <bean type="ognl.PropertyAccessor" name="java.util.List" class="com.opensymphony.xwork2.ognl.accessor.XWorkListPropertyAccessor" />
151     <bean type="ognl.PropertyAccessor" name="java.util.Set" class="com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor" />
152     <bean type="ognl.PropertyAccessor" name="java.util.Map" class="com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor" />
153     <bean type="ognl.PropertyAccessor" name="java.util.Collection" class="com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor" />
154     <bean type="ognl.PropertyAccessor" name="com.opensymphony.xwork2.ognl.ObjectProxy" class="com.opensymphony.xwork2.ognl.accessor.ObjectProxyPropertyAccessor" />
155     <bean type="ognl.PropertyAccessor" name="org.apache.struts2.dispatcher.HttpParameters" class="com.opensymphony.xwork2.ognl.accessor.HttpParametersPropertyAccessor" />
156     <bean type="ognl.PropertyAccessor" name="org.apache.struts2.dispatcher.Parameter" class="com.opensymphony.xwork2.ognl.accessor.ParameterPropertyAccessor" />
157 
158     <bean type="ognl.MethodAccessor" name="java.lang.Object" class="com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor" />
159     <bean type="ognl.MethodAccessor" name="com.opensymphony.xwork2.util.CompoundRoot" class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor" />
160 
161     <bean class="org.apache.struts2.views.jsp.ui.OgnlTool" />
162 
163     <bean type="org.apache.struts2.dispatcher.StaticContentLoader" class="org.apache.struts2.dispatcher.DefaultStaticContentLoader" name="struts" />
164     <bean type="com.opensymphony.xwork2.UnknownHandlerManager" class="com.opensymphony.xwork2.DefaultUnknownHandlerManager" name="struts" />
165 
166     <bean type="org.apache.struts2.dispatcher.DispatcherErrorHandler" name="struts" class="org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler" />
167     
168     <constant name="struts.dispatcher.errorHandler" value="struts" />
169 
170     <!--  Silly workarounds for OGNL since there is currently no way to flush its internal caches -->
171     <bean type="ognl.PropertyAccessor" name="java.util.ArrayList" class="com.opensymphony.xwork2.ognl.accessor.XWorkListPropertyAccessor" />
172     <bean type="ognl.PropertyAccessor" name="java.util.HashSet" class="com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor" />
173     <bean type="ognl.PropertyAccessor" name="java.util.HashMap" class="com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor" />
174 
175     <bean type="com.opensymphony.xwork2.security.ExcludedPatternsChecker" name="struts" class="com.opensymphony.xwork2.security.DefaultExcludedPatternsChecker" scope="prototype" />
176     <bean type="com.opensymphony.xwork2.security.AcceptedPatternsChecker" name="struts" class="com.opensymphony.xwork2.security.DefaultAcceptedPatternsChecker" scope="prototype" />
177 
178     <bean type="com.opensymphony.xwork2.config.providers.ValueSubstitutor" class="com.opensymphony.xwork2.config.providers.EnvsValueSubstitutor" scope="singleton"/>
179 
180     <package name="struts-default" abstract="true" strict-method-invocation="true">
181         <result-types>
182             <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
183             <result-type name="dispatcher" class="org.apache.struts2.result.ServletDispatcherResult" default="true"/>
184             <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
185             <result-type name="httpheader" class="org.apache.struts2.result.HttpHeaderResult"/>
186             <result-type name="redirect" class="org.apache.struts2.result.ServletRedirectResult"/>
187             <result-type name="redirectAction" class="org.apache.struts2.result.ServletActionRedirectResult"/>
188             <result-type name="stream" class="org.apache.struts2.result.StreamResult"/>
189             <result-type name="velocity" class="org.apache.struts2.result.VelocityResult"/>
190             <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
191             <result-type name="plainText" class="org.apache.struts2.result.PlainTextResult" />
192             <result-type name="postback" class="org.apache.struts2.result.PostbackResult" />
193         </result-types>
194 
195         <interceptors>
196             <interceptor name="alias" class="com.opensymphony.xwork2.interceptor.AliasInterceptor"/>
197             <interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
198             <interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
199             <interceptor name="conversionError" class="org.apache.struts2.interceptor.StrutsConversionErrorInterceptor"/>
200             <interceptor name="cookie" class="org.apache.struts2.interceptor.CookieInterceptor"/>
201             <interceptor name="cookieProvider" class="org.apache.struts2.interceptor.CookieProviderInterceptor"/>
202             <interceptor name="clearSession" class="org.apache.struts2.interceptor.ClearSessionInterceptor" />
203             <interceptor name="createSession" class="org.apache.struts2.interceptor.CreateSessionInterceptor" />
204             <interceptor name="debugging" class="org.apache.struts2.interceptor.debugging.DebuggingInterceptor" />
205             <interceptor name="execAndWait" class="org.apache.struts2.interceptor.ExecuteAndWaitInterceptor"/>
206             <interceptor name="exception" class="com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor"/>
207             <interceptor name="fileUpload" class="org.apache.struts2.interceptor.FileUploadInterceptor"/>
208             <interceptor name="i18n" class="org.apache.struts2.interceptor.I18nInterceptor"/>
209             <interceptor name="logger" class="com.opensymphony.xwork2.interceptor.LoggingInterceptor"/>
210             <interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
211             <interceptor name="scopedModelDriven" class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor"/>
212             <interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
213             <interceptor name="actionMappingParams" class="org.apache.struts2.interceptor.ActionMappingParametersInteceptor"/>
214             <interceptor name="prepare" class="com.opensymphony.xwork2.interceptor.PrepareInterceptor"/>
215             <interceptor name="staticParams" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>
216             <interceptor name="scope" class="org.apache.struts2.interceptor.ScopeInterceptor"/>
217             <interceptor name="servletConfig" class="org.apache.struts2.interceptor.ServletConfigInterceptor"/>
218             <interceptor name="timer" class="com.opensymphony.xwork2.interceptor.TimerInterceptor"/>
219             <interceptor name="token" class="org.apache.struts2.interceptor.TokenInterceptor"/>
220             <interceptor name="tokenSession" class="org.apache.struts2.interceptor.TokenSessionStoreInterceptor"/>
221             <interceptor name="validation" class="org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor"/>
222             <interceptor name="workflow" class="com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor"/>
223             <interceptor name="store" class="org.apache.struts2.interceptor.MessageStoreInterceptor" />
224             <interceptor name="checkbox" class="org.apache.struts2.interceptor.CheckboxInterceptor" />
225             <interceptor name="datetime" class="org.apache.struts2.interceptor.DateTextFieldInterceptor" />
226             <interceptor name="profiling" class="org.apache.struts2.interceptor.ProfilingActivationInterceptor" />
227             <interceptor name="roles" class="org.apache.struts2.interceptor.RolesInterceptor" />
228             <interceptor name="annotationWorkflow" class="com.opensymphony.xwork2.interceptor.annotations.AnnotationWorkflowInterceptor" />
229             <interceptor name="multiselect" class="org.apache.struts2.interceptor.MultiselectInterceptor" />
230 
231             <!-- Basic stack -->
232             <interceptor-stack name="basicStack">
233                 <interceptor-ref name="exception"/>
234                 <interceptor-ref name="servletConfig"/>
235                 <interceptor-ref name="prepare"/>
236                 <interceptor-ref name="checkbox"/>
237                 <interceptor-ref name="datetime"/>
238                 <interceptor-ref name="multiselect"/>
239                 <interceptor-ref name="actionMappingParams"/>
240                 <interceptor-ref name="params"/>
241                 <interceptor-ref name="conversionError"/>
242             </interceptor-stack>
243 
244             <!-- Sample validation and workflow stack -->
245             <interceptor-stack name="validationWorkflowStack">
246                 <interceptor-ref name="basicStack"/>
247                 <interceptor-ref name="validation"/>
248                 <interceptor-ref name="workflow"/>
249             </interceptor-stack>
250 
251             <!-- Sample file upload stack -->
252             <interceptor-stack name="fileUploadStack">
253                 <interceptor-ref name="fileUpload"/>
254                 <interceptor-ref name="basicStack"/>
255             </interceptor-stack>
256 
257             <!-- Sample model-driven stack  -->
258             <interceptor-stack name="modelDrivenStack">
259                 <interceptor-ref name="modelDriven"/>
260                 <interceptor-ref name="basicStack"/>
261             </interceptor-stack>
262 
263             <!-- Sample action chaining stack -->
264             <interceptor-stack name="chainStack">
265                 <interceptor-ref name="chain"/>
266                 <interceptor-ref name="basicStack"/>
267             </interceptor-stack>
268 
269             <!-- Sample i18n stack -->
270             <interceptor-stack name="i18nStack">
271                 <interceptor-ref name="i18n"/>
272                 <interceptor-ref name="basicStack"/>
273             </interceptor-stack>
274 
275             <!-- An example of the paramsPrepareParams trick. This stack
276                  is exactly the same as the defaultStack, except that it
277                  includes one extra interceptor before the prepare interceptor:
278                  the params interceptor.
279 
280                  This is useful for when you wish to apply parameters directly
281                  to an object that you wish to load externally (such as a DAO
282                  or database or service layer), but can't load that object
283                  until at least the ID parameter has been loaded. By loading
284                  the parameters twice, you can retrieve the object in the
285                  prepare() method, allowing the second params interceptor to
286                  apply the values on the object. -->
287             <interceptor-stack name="paramsPrepareParamsStack">
288                 <interceptor-ref name="exception"/>
289                 <interceptor-ref name="alias"/>
290                 <interceptor-ref name="i18n"/>
291                 <interceptor-ref name="checkbox"/>
292                 <interceptor-ref name="datetime"/>
293                 <interceptor-ref name="multiselect"/>
294                 <interceptor-ref name="params"/>
295                 <interceptor-ref name="servletConfig"/>
296                 <interceptor-ref name="prepare"/>
297                 <interceptor-ref name="chain"/>
298                 <interceptor-ref name="modelDriven"/>
299                 <interceptor-ref name="fileUpload"/>
300                 <interceptor-ref name="staticParams"/>
301                 <interceptor-ref name="actionMappingParams"/>
302                 <interceptor-ref name="params"/>
303                 <interceptor-ref name="conversionError"/>
304                 <interceptor-ref name="validation">
305                     <param name="excludeMethods">input,back,cancel,browse</param>
306                 </interceptor-ref>
307                 <interceptor-ref name="workflow">
308                     <param name="excludeMethods">input,back,cancel,browse</param>
309                 </interceptor-ref>
310             </interceptor-stack>
311 
312             <!-- A complete stack with all the common interceptors in place.
313                  Generally, this stack should be the one you use, though it
314                  may do more than you need. Also, the ordering can be
315                  switched around (ex: if you wish to have your servlet-related
316                  objects applied before prepare() is called, you'd need to move
317                  servletConfig interceptor up.
318 
319                  This stack also excludes from the normal validation and workflow
320                  the method names input, back, and cancel. These typically are
321                  associated with requests that should not be validated.
322                  -->
323             <interceptor-stack name="defaultStack">
324                 <interceptor-ref name="exception"/>
325                 <interceptor-ref name="alias"/>
326                 <interceptor-ref name="servletConfig"/>
327                 <interceptor-ref name="i18n"/>
328                 <interceptor-ref name="prepare"/>
329                 <interceptor-ref name="chain"/>
330                 <interceptor-ref name="scopedModelDriven"/>
331                 <interceptor-ref name="modelDriven"/>
332                 <interceptor-ref name="fileUpload"/>
333                 <interceptor-ref name="checkbox"/>
334                 <interceptor-ref name="datetime"/>
335                 <interceptor-ref name="multiselect"/>
336                 <interceptor-ref name="staticParams"/>
337                 <interceptor-ref name="actionMappingParams"/>
338                 <interceptor-ref name="params"/>
339                 <interceptor-ref name="conversionError"/>
340                 <interceptor-ref name="validation">
341                     <param name="excludeMethods">input,back,cancel,browse</param>
342                 </interceptor-ref>
343                 <interceptor-ref name="workflow">
344                     <param name="excludeMethods">input,back,cancel,browse</param>
345                 </interceptor-ref>
346                 <interceptor-ref name="debugging"/>
347             </interceptor-stack>
348 
349             <!-- The completeStack is here for backwards compatibility for
350                  applications that still refer to the defaultStack by the
351                  old name -->
352             <interceptor-stack name="completeStack">
353                 <interceptor-ref name="defaultStack"/>
354             </interceptor-stack>
355 
356             <!-- Sample execute and wait stack.
357                  Note: execAndWait should always be the *last* interceptor. -->
358             <interceptor-stack name="executeAndWaitStack">
359                 <interceptor-ref name="execAndWait">
360                     <param name="excludeMethods">input,back,cancel</param>
361                 </interceptor-ref>
362                 <interceptor-ref name="defaultStack"/>
363                 <interceptor-ref name="execAndWait">
364                     <param name="excludeMethods">input,back,cancel</param>
365                 </interceptor-ref>
366             </interceptor-stack>
367 
368        </interceptors>
369 
370         <default-interceptor-ref name="defaultStack"/>
371 
372         <default-class-ref class="com.opensymphony.xwork2.ActionSupport" />
373 
374         <global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index</global-allowed-methods>
375 
376     </package>
377 
378 </struts>
379 <?xml version="1.0" encoding="UTF-8" ?>
380 <!--
381 /*
382  * $Id$
383  *
384  * Licensed to the Apache Software Foundation (ASF) under one
385  * or more contributor license agreements.  See the NOTICE file
386  * distributed with this work for additional information
387  * regarding copyright ownership.  The ASF licenses this file
388  * to you under the Apache License, Version 2.0 (the
389  * "License"); you may not use this file except in compliance
390  * with the License.  You may obtain a copy of the License at
391  *
392  *  http://www.apache.org/licenses/LICENSE-2.0
393  *
394  * Unless required by applicable law or agreed to in writing,
395  * software distributed under the License is distributed on an
396  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
397  * KIND, either express or implied.  See the License for the
398  * specific language governing permissions and limitations
399  * under the License.
400  */
401 -->
402 
403 <!--
404     When declaring beans in this file you must either use name="struts" or don't name the bean at all.
405 
406     The name="struts" must be used when alias was defined in {@link org.apache.struts2.config.DefaultBeanSelectionProvider} -
407     it is then the default bean's name and {@link org.apache.struts2.config.DefaultBeanSelectionProvider} links name "struts"
408     with "default" (aliasing it)
409 
410     If name won't be defined then the "default" value will be used {@link com.opensymphony.xwork2.inject.Container#DEFAULT_NAME}
411     and {@link com.opensymphony.xwork2.inject.Inject}
412 -->
413 <!DOCTYPE struts PUBLIC
414     "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
415     "http://struts.apache.org/dtds/struts-2.5.dtd">
416 
417 <struts>
418 
419     <constant name="struts.excludedClasses"
420               value="
421                 java.lang.Object,
422                 java.lang.Runtime,
423                 java.lang.System,
424                 java.lang.Class,
425                 java.lang.ClassLoader,
426                 java.lang.Shutdown,
427                 java.lang.ProcessBuilder,
428                 ognl.OgnlContext,
429                 ognl.ClassResolver,
430                 ognl.TypeConverter,
431                 ognl.MemberAccess,
432                 ognl.DefaultMemberAccess,
433                 com.opensymphony.xwork2.ognl.SecurityMemberAccess,
434                 com.opensymphony.xwork2.ActionContext" />
435 
436     <!-- this must be valid regex, each '.' in package name must be escaped! -->
437     <!-- it's more flexible but slower than simple string comparison -->
438     <!-- constant name="struts.excludedPackageNamePatterns" value="^java\.lang\..*,^ognl.*,^(?!javax\.servlet\..+)(javax\..+)" / -->
439 
440     <!-- this is simpler version of the above used with string comparison -->
441     <constant name="struts.excludedPackageNames" value="java.lang.,ognl,javax" />
442 
443     <bean class="com.opensymphony.xwork2.ObjectFactory" name="struts"/>
444     <bean type="com.opensymphony.xwork2.factory.ResultFactory" name="struts" class="org.apache.struts2.factory.StrutsResultFactory" />
445     <bean type="com.opensymphony.xwork2.factory.ActionFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultActionFactory" />
446     <bean type="com.opensymphony.xwork2.factory.ConverterFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultConverterFactory" />
447     <bean type="com.opensymphony.xwork2.factory.InterceptorFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultInterceptorFactory" />
448     <bean type="com.opensymphony.xwork2.factory.ValidatorFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultValidatorFactory" />
449     <bean type="com.opensymphony.xwork2.factory.UnknownHandlerFactory" name="struts" class="com.opensymphony.xwork2.factory.DefaultUnknownHandlerFactory" />
450 
451     <bean type="com.opensymphony.xwork2.FileManager" class="com.opensymphony.xwork2.util.fs.DefaultFileManager" name="system" scope="singleton"/>
452     <bean type="com.opensymphony.xwork2.FileManagerFactory" class="com.opensymphony.xwork2.util.fs.DefaultFileManagerFactory" name="struts" scope="singleton"/>
453 
454     <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="struts" class="org.apache.struts2.factory.StrutsActionProxyFactory"/>
455     <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="prefix" class="org.apache.struts2.factory.PrefixBasedActionProxyFactory"/>
456 
457     <bean type="com.opensymphony.xwork2.conversion.ObjectTypeDeterminer" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultObjectTypeDeterminer"/>
458 
459     <bean type="com.opensymphony.xwork2.util.PatternMatcher" name="struts" class="com.opensymphony.xwork2.util.WildcardHelper" />
460     <bean type="com.opensymphony.xwork2.util.PatternMatcher" name="namedVariable" class="com.opensymphony.xwork2.util.NamedVariablePatternMatcher"/>
461     <bean type="com.opensymphony.xwork2.util.PatternMatcher" name="regex" class="org.apache.struts2.util.RegexPatternMatcher"/>
462 
463     <bean type="org.apache.struts2.util.ContentTypeMatcher" name="struts" class="org.apache.struts2.util.DefaultContentTypeMatcher"/>
464 
465     <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="struts" class="org.apache.struts2.dispatcher.mapper.DefaultActionMapper" />
466     <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="composite" class="org.apache.struts2.dispatcher.mapper.CompositeActionMapper" />
467     <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="restful" class="org.apache.struts2.dispatcher.mapper.RestfulActionMapper" />
468     <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="restful2" class="org.apache.struts2.dispatcher.mapper.Restful2ActionMapper" />
469 
470     <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta" class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" scope="prototype"/>
471     <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta-stream" class="org.apache.struts2.dispatcher.multipart.JakartaStreamMultiPartRequest" scope="prototype"/>
472 
473     <bean type="org.apache.struts2.views.TagLibraryDirectiveProvider" name="s" class="org.apache.struts2.views.DefaultTagLibrary" />
474     <bean type="org.apache.struts2.views.TagLibraryModelProvider" name="s" class="org.apache.struts2.views.DefaultTagLibrary" />
475 
476     <bean class="org.apache.struts2.views.freemarker.FreemarkerThemeTemplateLoader" />
477     <bean class="org.apache.struts2.views.freemarker.FreemarkerManager" name="struts" />
478     <bean class="org.apache.struts2.views.velocity.VelocityManager" name="struts" optional="true" />
479 
480     <bean class="org.apache.struts2.components.template.TemplateEngineManager" />
481     <bean type="org.apache.struts2.components.template.TemplateEngine" name="ftl" class="org.apache.struts2.components.template.FreemarkerTemplateEngine" />
482     <bean type="org.apache.struts2.components.template.TemplateEngine" name="vm" class="org.apache.struts2.components.template.VelocityTemplateEngine" />
483     <bean type="org.apache.struts2.components.template.TemplateEngine" name="jsp" class="org.apache.struts2.components.template.JspTemplateEngine" />
484 
485     <bean type="com.opensymphony.xwork2.conversion.impl.XWorkConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.XWorkConverter" />
486 
487     <bean type="com.opensymphony.xwork2.conversion.ConversionPropertiesProcessor" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultConversionPropertiesProcessor" />
488     <bean type="com.opensymphony.xwork2.conversion.ConversionFileProcessor" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultConversionFileProcessor" />
489     <bean type="com.opensymphony.xwork2.conversion.ConversionAnnotationProcessor" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultConversionAnnotationProcessor" />
490     <bean type="com.opensymphony.xwork2.conversion.TypeConverterCreator" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultTypeConverterCreator" />
491     <bean type="com.opensymphony.xwork2.conversion.TypeConverterHolder" name="struts" class="com.opensymphony.xwork2.conversion.impl.DefaultTypeConverterHolder" />
492 
493     <bean class="com.opensymphony.xwork2.conversion.impl.XWorkBasicConverter" />
494 
495     <bean type="com.opensymphony.xwork2.conversion.impl.CollectionConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.CollectionConverter" scope="singleton"/>
496     <bean type="com.opensymphony.xwork2.conversion.impl.ArrayConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.ArrayConverter" scope="singleton"/>
497     <bean type="com.opensymphony.xwork2.conversion.impl.DateConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.DateConverter" scope="singleton"/>
498     <bean type="com.opensymphony.xwork2.conversion.impl.NumberConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.NumberConverter" scope="singleton"/>
499     <bean type="com.opensymphony.xwork2.conversion.impl.StringConverter" name="struts" class="com.opensymphony.xwork2.conversion.impl.StringConverter" scope="singleton"/>
500 
501     <bean type="com.opensymphony.xwork2.TextProvider" name="struts" class="com.opensymphony.xwork2.TextProviderSupport" scope="prototype" />
502     <bean type="com.opensymphony.xwork2.LocaleProvider" name="struts" class="com.opensymphony.xwork2.DefaultLocaleProvider" scope="singleton" />
503 
504     <bean type="org.apache.struts2.components.UrlRenderer" name="struts" class="org.apache.struts2.components.ServletUrlRenderer"/>
505     <bean type="org.apache.struts2.views.util.UrlHelper" name="struts" class="org.apache.struts2.views.util.DefaultUrlHelper"/>
506 
507     <bean type="com.opensymphony.xwork2.util.ValueStackFactory" name="struts" class="com.opensymphony.xwork2.ognl.OgnlValueStackFactory" />
508     <bean type="com.opensymphony.xwork2.util.reflection.ReflectionProvider" name="struts" class="com.opensymphony.xwork2.ognl.OgnlReflectionProvider" />
509     <bean type="com.opensymphony.xwork2.util.reflection.ReflectionContextFactory" name="struts" class="com.opensymphony.xwork2.ognl.OgnlReflectionContextFactory" />
510 
511     <bean type="com.opensymphony.xwork2.TextProvider" name="system" class="com.opensymphony.xwork2.DefaultTextProvider" />
512     <bean type="com.opensymphony.xwork2.conversion.NullHandler" name="java.lang.Object" class="com.opensymphony.xwork2.conversion.impl.InstantiatingNullHandler" />
513 
514     <bean type="com.opensymphony.xwork2.validator.ActionValidatorManager" name="struts" class="com.opensymphony.xwork2.validator.AnnotationActionValidatorManager" />
515     <bean type="com.opensymphony.xwork2.validator.ActionValidatorManager" name="no-annotations" class="com.opensymphony.xwork2.validator.DefaultActionValidatorManager" />
516 
517     <bean type="com.opensymphony.xwork2.validator.ValidatorFactory" class="com.opensymphony.xwork2.validator.DefaultValidatorFactory"/>
518     <bean type="com.opensymphony.xwork2.validator.ValidatorFileParser" class="com.opensymphony.xwork2.validator.DefaultValidatorFileParser" />
519 
520     <bean class="com.opensymphony.xwork2.ognl.OgnlUtil" />
521 
522     <bean type="com.opensymphony.xwork2.util.TextParser" name="struts" class="com.opensymphony.xwork2.util.OgnlTextParser" scope="singleton"/>
523 
524     <bean type="ognl.PropertyAccessor" name="com.opensymphony.xwork2.util.CompoundRoot" class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor" />
525     <bean type="ognl.PropertyAccessor" name="java.lang.Object" class="com.opensymphony.xwork2.ognl.accessor.ObjectAccessor" />
526     <bean type="ognl.PropertyAccessor" name="java.util.Iterator" class="com.opensymphony.xwork2.ognl.accessor.XWorkIteratorPropertyAccessor" />
527     <bean type="ognl.PropertyAccessor" name="java.util.Enumeration" class="com.opensymphony.xwork2.ognl.accessor.XWorkEnumerationAccessor" />
528     <bean type="ognl.PropertyAccessor" name="java.util.List" class="com.opensymphony.xwork2.ognl.accessor.XWorkListPropertyAccessor" />
529     <bean type="ognl.PropertyAccessor" name="java.util.Set" class="com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor" />
530     <bean type="ognl.PropertyAccessor" name="java.util.Map" class="com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor" />
531     <bean type="ognl.PropertyAccessor" name="java.util.Collection" class="com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor" />
532     <bean type="ognl.PropertyAccessor" name="com.opensymphony.xwork2.ognl.ObjectProxy" class="com.opensymphony.xwork2.ognl.accessor.ObjectProxyPropertyAccessor" />
533     <bean type="ognl.PropertyAccessor" name="org.apache.struts2.dispatcher.HttpParameters" class="com.opensymphony.xwork2.ognl.accessor.HttpParametersPropertyAccessor" />
534     <bean type="ognl.PropertyAccessor" name="org.apache.struts2.dispatcher.Parameter" class="com.opensymphony.xwork2.ognl.accessor.ParameterPropertyAccessor" />
535 
536     <bean type="ognl.MethodAccessor" name="java.lang.Object" class="com.opensymphony.xwork2.ognl.accessor.XWorkMethodAccessor" />
537     <bean type="ognl.MethodAccessor" name="com.opensymphony.xwork2.util.CompoundRoot" class="com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor" />
538 
539     <bean class="org.apache.struts2.views.jsp.ui.OgnlTool" />
540 
541     <bean type="org.apache.struts2.dispatcher.StaticContentLoader" class="org.apache.struts2.dispatcher.DefaultStaticContentLoader" name="struts" />
542     <bean type="com.opensymphony.xwork2.UnknownHandlerManager" class="com.opensymphony.xwork2.DefaultUnknownHandlerManager" name="struts" />
543 
544     <bean type="org.apache.struts2.dispatcher.DispatcherErrorHandler" name="struts" class="org.apache.struts2.dispatcher.DefaultDispatcherErrorHandler" />
545     
546     <constant name="struts.dispatcher.errorHandler" value="struts" />
547 
548     <!--  Silly workarounds for OGNL since there is currently no way to flush its internal caches -->
549     <bean type="ognl.PropertyAccessor" name="java.util.ArrayList" class="com.opensymphony.xwork2.ognl.accessor.XWorkListPropertyAccessor" />
550     <bean type="ognl.PropertyAccessor" name="java.util.HashSet" class="com.opensymphony.xwork2.ognl.accessor.XWorkCollectionPropertyAccessor" />
551     <bean type="ognl.PropertyAccessor" name="java.util.HashMap" class="com.opensymphony.xwork2.ognl.accessor.XWorkMapPropertyAccessor" />
552 
553     <bean type="com.opensymphony.xwork2.security.ExcludedPatternsChecker" name="struts" class="com.opensymphony.xwork2.security.DefaultExcludedPatternsChecker" scope="prototype" />
554     <bean type="com.opensymphony.xwork2.security.AcceptedPatternsChecker" name="struts" class="com.opensymphony.xwork2.security.DefaultAcceptedPatternsChecker" scope="prototype" />
555 
556     <bean type="com.opensymphony.xwork2.config.providers.ValueSubstitutor" class="com.opensymphony.xwork2.config.providers.EnvsValueSubstitutor" scope="singleton"/>
557 
558     <package name="struts-default" abstract="true" strict-method-invocation="true">
559         <result-types>
560             <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
561             <result-type name="dispatcher" class="org.apache.struts2.result.ServletDispatcherResult" default="true"/>
562             <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
563             <result-type name="httpheader" class="org.apache.struts2.result.HttpHeaderResult"/>
564             <result-type name="redirect" class="org.apache.struts2.result.ServletRedirectResult"/>
565             <result-type name="redirectAction" class="org.apache.struts2.result.ServletActionRedirectResult"/>
566             <result-type name="stream" class="org.apache.struts2.result.StreamResult"/>
567             <result-type name="velocity" class="org.apache.struts2.result.VelocityResult"/>
568             <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
569             <result-type name="plainText" class="org.apache.struts2.result.PlainTextResult" />
570             <result-type name="postback" class="org.apache.struts2.result.PostbackResult" />
571         </result-types>
572 
573         <interceptors>
574             <interceptor name="alias" class="com.opensymphony.xwork2.interceptor.AliasInterceptor"/>
575             <interceptor name="autowiring" class="com.opensymphony.xwork2.spring.interceptor.ActionAutowiringInterceptor"/>
576             <interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>
577             <interceptor name="conversionError" class="org.apache.struts2.interceptor.StrutsConversionErrorInterceptor"/>
578             <interceptor name="cookie" class="org.apache.struts2.interceptor.CookieInterceptor"/>
579             <interceptor name="cookieProvider" class="org.apache.struts2.interceptor.CookieProviderInterceptor"/>
580             <interceptor name="clearSession" class="org.apache.struts2.interceptor.ClearSessionInterceptor" />
581             <interceptor name="createSession" class="org.apache.struts2.interceptor.CreateSessionInterceptor" />
582             <interceptor name="debugging" class="org.apache.struts2.interceptor.debugging.DebuggingInterceptor" />
583             <interceptor name="execAndWait" class="org.apache.struts2.interceptor.ExecuteAndWaitInterceptor"/>
584             <interceptor name="exception" class="com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor"/>
585             <interceptor name="fileUpload" class="org.apache.struts2.interceptor.FileUploadInterceptor"/>
586             <interceptor name="i18n" class="org.apache.struts2.interceptor.I18nInterceptor"/>
587             <interceptor name="logger" class="com.opensymphony.xwork2.interceptor.LoggingInterceptor"/>
588             <interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>
589             <interceptor name="scopedModelDriven" class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor"/>
590             <interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>
591             <interceptor name="actionMappingParams" class="org.apache.struts2.interceptor.ActionMappingParametersInteceptor"/>
592             <interceptor name="prepare" class="com.opensymphony.xwork2.interceptor.PrepareInterceptor"/>
593             <interceptor name="staticParams" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>
594             <interceptor name="scope" class="org.apache.struts2.interceptor.ScopeInterceptor"/>
595             <interceptor name="servletConfig" class="org.apache.struts2.interceptor.ServletConfigInterceptor"/>
596             <interceptor name="timer" class="com.opensymphony.xwork2.interceptor.TimerInterceptor"/>
597             <interceptor name="token" class="org.apache.struts2.interceptor.TokenInterceptor"/>
598             <interceptor name="tokenSession" class="org.apache.struts2.interceptor.TokenSessionStoreInterceptor"/>
599             <interceptor name="validation" class="org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor"/>
600             <interceptor name="workflow" class="com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor"/>
601             <interceptor name="store" class="org.apache.struts2.interceptor.MessageStoreInterceptor" />
602             <interceptor name="checkbox" class="org.apache.struts2.interceptor.CheckboxInterceptor" />
603             <interceptor name="datetime" class="org.apache.struts2.interceptor.DateTextFieldInterceptor" />
604             <interceptor name="profiling" class="org.apache.struts2.interceptor.ProfilingActivationInterceptor" />
605             <interceptor name="roles" class="org.apache.struts2.interceptor.RolesInterceptor" />
606             <interceptor name="annotationWorkflow" class="com.opensymphony.xwork2.interceptor.annotations.AnnotationWorkflowInterceptor" />
607             <interceptor name="multiselect" class="org.apache.struts2.interceptor.MultiselectInterceptor" />
608 
609             <!-- Basic stack -->
610             <interceptor-stack name="basicStack">
611                 <interceptor-ref name="exception"/>
612                 <interceptor-ref name="servletConfig"/>
613                 <interceptor-ref name="prepare"/>
614                 <interceptor-ref name="checkbox"/>
615                 <interceptor-ref name="datetime"/>
616                 <interceptor-ref name="multiselect"/>
617                 <interceptor-ref name="actionMappingParams"/>
618                 <interceptor-ref name="params"/>
619                 <interceptor-ref name="conversionError"/>
620             </interceptor-stack>
621 
622             <!-- Sample validation and workflow stack -->
623             <interceptor-stack name="validationWorkflowStack">
624                 <interceptor-ref name="basicStack"/>
625                 <interceptor-ref name="validation"/>
626                 <interceptor-ref name="workflow"/>
627             </interceptor-stack>
628 
629             <!-- Sample file upload stack -->
630             <interceptor-stack name="fileUploadStack">
631                 <interceptor-ref name="fileUpload"/>
632                 <interceptor-ref name="basicStack"/>
633             </interceptor-stack>
634 
635             <!-- Sample model-driven stack  -->
636             <interceptor-stack name="modelDrivenStack">
637                 <interceptor-ref name="modelDriven"/>
638                 <interceptor-ref name="basicStack"/>
639             </interceptor-stack>
640 
641             <!-- Sample action chaining stack -->
642             <interceptor-stack name="chainStack">
643                 <interceptor-ref name="chain"/>
644                 <interceptor-ref name="basicStack"/>
645             </interceptor-stack>
646 
647             <!-- Sample i18n stack -->
648             <interceptor-stack name="i18nStack">
649                 <interceptor-ref name="i18n"/>
650                 <interceptor-ref name="basicStack"/>
651             </interceptor-stack>
652 
653             <!-- An example of the paramsPrepareParams trick. This stack
654                  is exactly the same as the defaultStack, except that it
655                  includes one extra interceptor before the prepare interceptor:
656                  the params interceptor.
657 
658                  This is useful for when you wish to apply parameters directly
659                  to an object that you wish to load externally (such as a DAO
660                  or database or service layer), but can't load that object
661                  until at least the ID parameter has been loaded. By loading
662                  the parameters twice, you can retrieve the object in the
663                  prepare() method, allowing the second params interceptor to
664                  apply the values on the object. -->
665             <interceptor-stack name="paramsPrepareParamsStack">
666                 <interceptor-ref name="exception"/>
667                 <interceptor-ref name="alias"/>
668                 <interceptor-ref name="i18n"/>
669                 <interceptor-ref name="checkbox"/>
670                 <interceptor-ref name="datetime"/>
671                 <interceptor-ref name="multiselect"/>
672                 <interceptor-ref name="params"/>
673                 <interceptor-ref name="servletConfig"/>
674                 <interceptor-ref name="prepare"/>
675                 <interceptor-ref name="chain"/>
676                 <interceptor-ref name="modelDriven"/>
677                 <interceptor-ref name="fileUpload"/>
678                 <interceptor-ref name="staticParams"/>
679                 <interceptor-ref name="actionMappingParams"/>
680                 <interceptor-ref name="params"/>
681                 <interceptor-ref name="conversionError"/>
682                 <interceptor-ref name="validation">
683                     <param name="excludeMethods">input,back,cancel,browse</param>
684                 </interceptor-ref>
685                 <interceptor-ref name="workflow">
686                     <param name="excludeMethods">input,back,cancel,browse</param>
687                 </interceptor-ref>
688             </interceptor-stack>
689 
690             <!-- A complete stack with all the common interceptors in place.
691                  Generally, this stack should be the one you use, though it
692                  may do more than you need. Also, the ordering can be
693                  switched around (ex: if you wish to have your servlet-related
694                  objects applied before prepare() is called, you'd need to move
695                  servletConfig interceptor up.
696 
697                  This stack also excludes from the normal validation and workflow
698                  the method names input, back, and cancel. These typically are
699                  associated with requests that should not be validated.
700                  -->
701             <interceptor-stack name="defaultStack">
702                 <interceptor-ref name="exception"/>
703                 <interceptor-ref name="alias"/>
704                 <interceptor-ref name="servletConfig"/>
705                 <interceptor-ref name="i18n"/>
706                 <interceptor-ref name="prepare"/>
707                 <interceptor-ref name="chain"/>
708                 <interceptor-ref name="scopedModelDriven"/>
709                 <interceptor-ref name="modelDriven"/>
710                 <interceptor-ref name="fileUpload"/>
711                 <interceptor-ref name="checkbox"/>
712                 <interceptor-ref name="datetime"/>
713                 <interceptor-ref name="multiselect"/>
714                 <interceptor-ref name="staticParams"/>
715                 <interceptor-ref name="actionMappingParams"/>
716                 <interceptor-ref name="params"/>
717                 <interceptor-ref name="conversionError"/>
718                 <interceptor-ref name="validation">
719                     <param name="excludeMethods">input,back,cancel,browse</param>
720                 </interceptor-ref>
721                 <interceptor-ref name="workflow">
722                     <param name="excludeMethods">input,back,cancel,browse</param>
723                 </interceptor-ref>
724                 <interceptor-ref name="debugging"/>
725             </interceptor-stack>
726 
727             <!-- The completeStack is here for backwards compatibility for
728                  applications that still refer to the defaultStack by the
729                  old name -->
730             <interceptor-stack name="completeStack">
731                 <interceptor-ref name="defaultStack"/>
732             </interceptor-stack>
733 
734             <!-- Sample execute and wait stack.
735                  Note: execAndWait should always be the *last* interceptor. -->
736             <interceptor-stack name="executeAndWaitStack">
737                 <interceptor-ref name="execAndWait">
738                     <param name="excludeMethods">input,back,cancel</param>
739                 </interceptor-ref>
740                 <interceptor-ref name="defaultStack"/>
741                 <interceptor-ref name="execAndWait">
742                     <param name="excludeMethods">input,back,cancel</param>
743                 </interceptor-ref>
744             </interceptor-stack>
745 
746        </interceptors>
747 
748         <default-interceptor-ref name="defaultStack"/>
749 
750         <default-class-ref class="com.opensymphony.xwork2.ActionSupport" />
751 
752         <global-allowed-methods>execute,input,back,cancel,browse,save,delete,list,index</global-allowed-methods>
753 
754     </package>
755 
756 </struts>
View Code

<bean>标签

  bean标签有一个必须属性那就是class,指定类名,基本上很少需要扩展,主要有两个作用

    |- 创建的Bean实例作为Struts2框架的核心组件使用。

    |-  Bean的静态方法需要一个值注入。

  六个属性:

    |-class:指定类名

    |-type:指定实现的接口

    |-name:指定唯一的名字

    |-scope:指定作用范围(defaultsingletonrequestsessionthread)

    |-static:指定是不是需要注入静态方法

    |-sptional:指定这个bean是不是可选的

<constant/>标签

  用来定制容器的一些属性,比如限制上传文件的大小之类的,指明具体实现哪个接口

  |-name:常量的名字

  |-value:常量的值

<include/>标签

  用来引入配置文件

  例: <include file="Hello.xml"/>

<package/>标签

  |- name(必须):定义一个包的名字,可以给别的包引用

  |- extends:用来继承别的包;例如继承默认的包extends="struts-default",继承多个包的时候用逗号分隔

  |- namespace:用来划分模块,默认的namespace是一个""(空字符串),在访问的时候需要在路径上加上namespace,在不同的namespace里面可以有相同名字的action

  |-abstract:定义一个抽象包,包里不需要定义action,默认的struts-default包就是一个抽象包

<result-types/>标签

  在<result-types>标签里面可以定义很多个<result-type>

  一个action在执行完之后,会返回一个字符串,这个字符串的值就用来选择一个result,返回到出力中。这个字符串的值在ActionSupport类中提供了以下几个固定值,当然我们也可以根据自己的实际情况来自定义。

  String SUCCESS="success";

  String NONE="none";

  String EOOR="error";

  String INPUT="input";

  String LOGIN="login";

还可以通过default选项来把这个result设置为默认的result,当没有其他的result匹配的时候,这个默认的就会被匹配。

 

在<result/>标签中,除了需要提供一个匹配的名字外,还有一个可选的type如下:

  Chain Result:用来连接到另一个action

  Dispatcher Result:转发(默认)

  Redirect Reslut:重定向

  Redirect Action Result:用来重定向到一个action

  当然还有  HttpHeader Result、FreeMarker Result、Stream Result、Velocity Result、XSL Result、PlainText Result、Tiles 2 Result、Tiles 3 Result、Postback Result、JSON Result等等

  全局reslult

  有的时候一些result是很多地方都需要使用的,就可以直接定义一个global-result,然后在其他地方都可以引用它。

<global-results>
    <result name="error">/Error.jsp</result>
    <result name="invalid.token">/Error.jsp</result>
    <result name="login" type="redirectAction">Logon!input</result>
</global-results>

  在给result指定跳转的目的地的时候,还可以使用动态的result,使用EL表达式来实现访问action的属性。就像使用Struts2的标签一样。

 

<interceptors/>标签

  在interceptors标签里面可以定义多个</interceptor>和<interceptor-stack/>

 

示例:

 1 <package name="default" extends="struts-default">
 2    <interceptors>
 3         <interceptor name="timer" class=".."/>
 4         <interceptor name="logger" class=".."/>
 5         <interceptor-stack name="myStack">
 6            <interceptor-ref name="timer"/>
 7            <interceptor-ref name="logger"/>
 8         </interceptor-stack>
 9     </interceptors>
10  
11 <action name="login"
12      class="tutuorial.Login">
13          <interceptor-ref name="myStack"/>
14          <result name="input">login.jsp</result>
15          <result name="success"
16              type="redirectAction">/secure/home</result>
17 </action>
18 </package>
View Code

<action/>标签

  |-name:给action指定一个唯一的名字

  |-class:action对应的类

  |-method:指定类的入口方法

  |-converter:类型转换器

 在action标签中,支持使用通配符(wildcard),

<default-action-ref/>

  当一个请求的action name不能找到匹配的时候,就可以通过这个指定一个默认的,一般用于指定页面找不到的404页面。

通配符

例:

<action name="/edit*" class="org.apache.struts.webapp.example.Edit{1}Action">
    <result name="failure">/mainMenu.jsp</result>
    <result>{1}.jsp</result>
</action>

*:匹配零个或多个字符,除了‘/’

**:匹配零个或多个字符,包括‘/’

\*:匹配'*'

\\:匹配‘/’

 

posted @ 2017-01-21 14:39  Ouka傅  阅读(1348)  评论(0编辑  收藏  举报