O(∩_∩)O
(*@ο@*)
 每学习一个框架,我们都免不了要学习一些关于的配置文件,struts2也不例外,下面我就讲一下struts2中几个主要的配置文件这个文件是struts2框架默认加载的配置文件。它定义struts2一些核心的bean和拦截器

 

       每学习一个框架,我们都免不了要学习一些关于的配置文件,struts2也不例外,下面我就讲一下struts2中几个主要的配置文件。

1) struts-default.xml

这个文件是struts2框架默认加载的配置文件。它定义struts2一些核心的bean和拦截器。

 

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts PUBLIC

    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

   <bean class="com.opensymphony.xwork2.ObjectFactory" name="xwork" />

   <bean type="com.opensymphony.xwork2.ActionProxyFactory" name="struts" class="org.apache.struts2.impl.StrutsActionProxyFactory"/>

   <bean type="com.opensymphony.xwork2.util.ObjectTypeDeterminer" name="tiger" class="com.opensymphony.xwork2.util.GenericsObjectTypeDeterminer"/>

   <bean type="com.opensymphony.xwork2.util.ObjectTypeDeterminer" name="struts" class="com.opensymphony.xwork2.util.DefaultObjectTypeDeterminer"/>

   <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="struts" class="org.apache.struts2.dispatcher.mapper.DefaultActionMapper" />

   <bean type="org.apache.struts2.dispatcher.mapper.ActionMapper" name="restful" class="org.apache.struts2.dispatcher.mapper.RestfulActionMapper" />

 

  <bean type="org.apache.struts2.dispatcher.multipart.MultiPartRequest" name="jakarta" class="org.apache.struts2.dispatcher.multipart.JakartaMultiPartRequest" scope="default" optional="true" />

 <bean type="org.apache.struts2.views.TagLibrary" name="s" class="org.apache.struts2.views.DefaultTagLibrary" />

 <bean class="org.apache.struts2.views.freemarker.FreemarkerManager" name="struts" optional="true"/>

  <bean type="org.apache.struts2.components.template.TemplateEngine" name="ftl" class="org.apache.struts2.components.template.FreemarkerTemplateEngine" />

    <bean type="org.apache.struts2.components.template.TemplateEngine" name="jsp" class="org.apache.struts2.components.template.JspTemplateEngine" />

   <bean type="com.opensymphony.xwork2.TextProvider" name="xwork1" class="com.opensymphony.xwork2.TextProviderSupport" />

 

  <bean class="com.opensymphony.xwork2.ObjectFactory" static="true" />

   <bean class="com.opensymphony.xwork2.util.OgnlValueStack" static="true" />

" border="0" />    <bean class="org.apache.struts2.components.Include" static="true" />

" border="0" />    <bean class="org.apache.struts2.views.util.ContextUtil" static="true" />

" border="0" /><!-- 定义Struts2默认包-->

" border="0" />    <!-- 结果类型的种类-->

" border="0" />            <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>

" border="0" />            <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>

" border="0" />            <result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/>

" border="0" />            <result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/>

" border="0" />            <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>

" border="0" />            <result-type name="redirect-action" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/>

" border="0" />        </result-types>

" border="0" /><!--struts2中拦截器的定义-->

" border="0" />        <!--实现在不同请求中相似参数别名的准换-->

" border="0" />            <!--与Spring整合时自动装配的拦截器-->

" border="0" />            <!--构建一个action链,使当前action可以访问前一个action,与<result-type="chain" " border="0" />            <interceptor name="chain" class="com.opensymphony.xwork2.interceptor.ChainingInterceptor"/>

" border="0" />            <interceptor name="conversionError" class="org.apache.struts2.interceptor.StrutsConversionErrorInterceptor"/>

" border="0" />            <interceptor name="cookie" class="org.apache.struts2.interceptor.CookieInterceptor"/>

" border="0" />            <interceptor name="createSession" class="org.apache.struts2.interceptor.CreateSessionInterceptor" />

" border="0" />            <interceptor name="debugging" class="org.apache.struts2.interceptor.debugging.DebuggingInterceptor" />

" border="0" />            <interceptor name="externalRef" class="com.opensymphony.xwork2.interceptor.ExternalReferencesInterceptor"/>

" border="0" />            <interceptor name="execAndWait" class="org.apache.struts2.interceptor.ExecuteAndWaitInterceptor"/>

" border="0" />            <interceptor name="exception" class="com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor"/>

" border="0" />            <interceptor name="fileUpload" class="org.apache.struts2.interceptor.FileUploadInterceptor"/>

" border="0" />            <interceptor name="i18n" class="com.opensymphony.xwork2.interceptor.I18nInterceptor"/>

" border="0" />            <interceptor name="logger" class="com.opensymphony.xwork2.interceptor.LoggingInterceptor"/>

" border="0" />            <interceptor name="modelDriven" class="com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>

" border="0" />            <interceptor name="scopedModelDriven" class="com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor"/>

" border="0" />            <interceptor name="params" class="com.opensymphony.xwork2.interceptor.ParametersInterceptor"/>

" border="0" />            <interceptor name="prepare" class="com.opensymphony.xwork2.interceptor.PrepareInterceptor"/>

" border="0" />            <interceptor name="staticParams" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>

" border="0" />            <interceptor name="scope" class="org.apache.struts2.interceptor.ScopeInterceptor"/>

" border="0" />            <interceptor name="servletConfig" class="org.apache.struts2.interceptor.ServletConfigInterceptor"/>

" border="0" />            <interceptor name="sessionAutowiring" class="org.apache.struts2.spring.interceptor.SessionContextAutowiringInterceptor"/>

" border="0" />            <interceptor name="timer" class="com.opensymphony.xwork2.interceptor.TimerInterceptor"/>

" border="0" />            <interceptor name="token" class="org.apache.struts2.interceptor.TokenInterceptor"/>

" border="0" />            <interceptor name="tokenSession" class="org.apache.struts2.interceptor.TokenSessionStoreInterceptor"/>

" border="0" />            <interceptor name="validation" class="org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor"/>

" border="0" />            <interceptor name="workflow" class="com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor"/>

" border="0" />            <interceptor name="store" class="org.apache.struts2.interceptor.MessageStoreInterceptor" />

" border="0" />            <interceptor name="checkbox" class="org.apache.struts2.interceptor.CheckboxInterceptor" />

" border="0" />            <!--JAAS服务拦截器-->

" border="0" />

" border="0" />            <interceptor-stack name="basicStack">

" border="0" />                <interceptor-ref name="servletConfig"/>

" border="0" />                <interceptor-ref name="checkbox"/>

" border="0" />                <interceptor-ref name="conversionError"/>

" border="0" />

" border="0" />            <interceptor-stack name="validationWorkflowStack">

" border="0" />                <interceptor-ref name="validation"/>

" border="0" />            </interceptor-stack>

" border="0" />            <!-- 文件上传的拦截器栈 -->

" border="0" />                <interceptor-ref name="fileUpload"/>

" border="0" />            </interceptor-stack>

" border="0" />            <!-- model-driven 栈  -->

" border="0" />                <interceptor-ref name="modelDriven"/>

" border="0" />            </interceptor-stack>

" border="0" />            <!-- action链的拦截器栈 -->

" border="0" />                <interceptor-ref name="chain"/>

" border="0" />            </interceptor-stack>

" border="0" />            <!--  i18n 拦截器栈 -->

" border="0" />                <interceptor-ref name="i18n"/>

" border="0" />            </interceptor-stack>

" border="0" />            <!-- 结合preparable和ModenDriven拦截器-->

" border="0" />                <interceptor-ref name="exception"/>

" border="0" />                <interceptor-ref name="params"/>

" border="0" />                <interceptor-ref name="prepare"/>

" border="0" />                <interceptor-ref name="chain"/>

" border="0" />                <interceptor-ref name="fileUpload"/>

" border="0" />                <interceptor-ref name="staticParams"/>

" border="0" />                <interceptor-ref name="conversionError"/>

" border="0" />                    <param name="excludeMethods">input,back,cancel</param>

" border="0" />                <interceptor-ref name="workflow">

" border="0" />                </interceptor-ref>

" border="0" />

" border="0" />            <interceptor-stack name="defaultStack">

" border="0" />                <interceptor-ref name="alias"/>

" border="0" />                <interceptor-ref name="prepare"/>

" border="0" />                <interceptor-ref name="chain"/>

" border="0" />                <interceptor-ref name="profiling"/>

" border="0" />                <interceptor-ref name="modelDriven"/>

" border="0" />                <interceptor-ref name="checkbox"/>

" border="0" />                <interceptor-ref name="params">

" border="0" />                </interceptor-ref>

" border="0" />                <interceptor-ref name="validation">

" border="0" />                </interceptor-ref>

" border="0" />                    <param name="excludeMethods">input,back,cancel,browse</param>

" border="0" />            </interceptor-stack>

" border="0" />            <interceptor-stack name="completeStack">

" border="0" />            </interceptor-stack>

" border="0" />            

" border="0" />                <interceptor-ref name="execAndWait">

" border="0" />                </interceptor-ref>

" border="0" />                <interceptor-ref name="execAndWait">

" border="0" />                </interceptor-ref>

" border="0" />

" border="0" />            <interceptor name="external-ref" class="com.opensymphony.xwork2.interceptor.ExternalReferencesInterceptor"/>

" border="0" />            <interceptor name="static-params" class="com.opensymphony.xwork2.interceptor.StaticParametersInterceptor"/>

" border="0" />            <interceptor name="servlet-config" class="org.apache.struts2.interceptor.ServletConfigInterceptor"/>

" border="0" />

" border="0" /><!--定义默认拦截器为"defaultStack"-->

" border="0" />    </package>

" border="0" /></struts>

" border="0" /><?xml version="1.0" encoding="GBK"?>

" border="0" /><!DOCTYPE struts PUBLIC

" border="0" />"http://struts.apache.org/dtds/struts-2.0.dtd">

" border="0" /><struts>

" border="0" /><constant name="" value="" />

" border="0" /><bean type="" name="" class="" scope="" static="" optional="" />

" border="0" /><include file="" />

" border="0" /><package name="必填的包名" extends="" namespace="" abstract=""

" border="0" /><!-- 该元素可以出现,也可以不出现,最多出现一次 -->

" border="0" /><!-- 该元素必须出现,可以出现无限多次-->

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /></result-type>

" border="0" /><!-- 该元素可以出现,也可以不出现,最多出现一次 -->

" border="0" /><!-- 该元素的interceptor元素和interceptor-stack至少出现其中之一,

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /></interceptor>

" border="0" /><interceptor-stack name="">

" border="0" /><interceptor-ref name="">

" border="0" /><param name="参数名">参数值</param>*

" border="0" /></interceptor-stack>

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /></default-interceptor-ref>

" border="0" /><default-action-ref name="">

" border="0" /><param name="参数名">参数值</param>*

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /><!-- 该元素必须出现,可以出现无限多次-->

" border="0" /><!-- 该字符串内容可以出现0次或多次 -->

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /></result>

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /><!-- 该元素必须出现,可以出现无限多次-->

" border="0" />异常处理资源

" border="0" /><param name="参数名">参数值</param>*

" border="0" /></global-exception-mappings>

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" />映射资源

" border="0" /><param name="参数名">参数值</param>*

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /></interceptor-ref>

" border="0" /><exception-mapping name="" exception="" result="">

" border="0" /><!-- 下面元素可以出现0次,也可以无限多次 -->

" border="0" /></exception-mapping>

" border="0" /></package>*

" border="0" />

" border="0" />

" border="0" />### 指定加载struts2配置文件管理器,默认为org.apache.struts2.config.DefaultConfiguration

" border="0" /># struts.configuration=org.apache.struts2.config.DefaultConfiguration

" border="0" />### 设置默认的locale和字符编码

" border="0" />struts.i18n.encoding=UTF-8

" border="0" />

" border="0" /># struts.objectFactory = spring

" border="0" />### 指定spring框架的装配模式

" border="0" />struts.objectFactory.spring.autoWire = name

" border="0" />### 该属性指定整合spring时,是否对bean进行缓存,值为true or false,默认为true.

" border="0" />

" border="0" />#struts.objectTypeDeterminer = tiger

" border="0" />

" border="0" /># struts.multipart.parser=cos

" border="0" />struts.multipart.parser=jakarta

" border="0" />struts.multipart.saveDir=

" border="0" />

" border="0" /># struts.custom.properties=application,org/apache/struts2/extension/custom

" border="0" />### 指定请求url与action映射器,默认为org.apache.struts2.dispatcher.mapper.DefaultActionMapper

" border="0" />

" border="0" />struts.action.extension=action

" border="0" />### 被 FilterDispatcher使用

" border="0" />### 如果为 false 则静态内容必须位于 <context_path>/struts

" border="0" />

" border="0" />### 指定浏览器是否缓存静态内容,测试阶段设置为false,发布阶段设置为true.

" border="0" />

" border="0" />struts.enable.DynamicMethodInvocation = true

" border="0" />### 设置是否可以在action中使用斜线,默认为false不可以,想使用需设置为true.

" border="0" />

" border="0" />struts.tag.altSyntax=true

" border="0" />

" border="0" />### - struts.configuration.xml.reload = true

" border="0" />struts.devMode = false

" border="0" />### 设置是否每次请求,都重新加载资源文件,默认值为false.

" border="0" />

" border="0" />### 默认的UI主题为xhtml,可以为simple,xhtml或ajax

" border="0" />###模板目录

" border="0" />#设置模板类型. 可以为 ftl, vm, or jsp

" border="0" />

" border="0" />struts.velocity.configfile = velocity.properties

" border="0" />### 设置velocity的context.

" border="0" />

" border="0" />struts.velocity.toolboxlocation=

" border="0" />### 指定web应用的端口.

" border="0" />### 指定加密端口

" border="0" />### 设置生成url时,是否包含参数.值可以为: none, get or all

" border="0" />

" border="0" /># struts.custom.i18n.resources=testmessages,testmessages2

" border="0" />### 对于一些web应用服务器不能处理HttpServletRequest.getParameterMap()

" border="0" />struts.dispatcher.parametersWorkaround = false

" border="0" />### 指定freemarker管理器

" border="0" />

" border="0" />### 效果相当于把template拷贝到 WEB_APP/templates.

" border="0" />

" border="0" />struts.freemarker.wrapper.altMap=true

" border="0" />### 指定xslt result是否使用样式表缓存.开发阶段设为true,发布阶段设为false.

" border="0" />

" border="0" />struts.configuration.files=struts-default.xml,struts-plugin.xml,struts.xml

" border="0" />### 设定是否一直在最后一个slash之前的任何位置选定namespace.

" border="0" />

posted on 2010-02-08 13:39 sai7752 阅读(418) 评论(0)  编辑  收藏 所属分类: Java网络应用资料

只有注册用户登录后才能发表评论。


网站导航: