struts2.xml文件的结构

<struts>
<!--通过constant元素来配置struts2的属性-->
<!--指定struts2的国际化资源文件的baseName为mess,在struts.xml文件中设置-->
<constant name="struts.custom.i18n.resources" valu="mess"/>
</struts>


<!--在struts.properties文件中设置-->
#指定了struts2应用处于开发阶段
struts.devMode=true


<!--在web.xml文件中配置struts2的常量-->
<filter>
<!--指定struts2的核心Filter-->
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsAndPrepareAndExecuteFilter</filter-class>
<!--通过init-param元素配置struts2的常量-->
<init-param>
<param-name>struts.custom.i18n.resources</param-name>
<param-value>mess</param-value>
</init-param>
</filter>
<!--在实际开发中推荐使用struts.xml文件中配置struts.xml常量-->




<!--struts.xml文件结构-->
<?xml version="1.0" encoding="gbk"?>
<!--下面指定struts2的配置文件的DTD-->
<!DOCTYPE struts PUBLIC
...>
<!--一以下是struts2配置文件的根元素-->
<struts order="">
<!--以下元素可以出现0次,也可以出现无数次-->
<constant name="" value=""/>
<!--下面元素可以出现0次,也可以出现无数次-->
<bean type="" name="" class="" scope="" static="" optional=""/>
<!--下面元素可以出现0次,也可以出现无数次-->
<include file="">
<!--package元素是struts的配置文件的核心,该元素可以出现0次,也可以出现无数次-->
<package name="必填的包名" extends="" namespace="" abstract="" externalReferenceResolver=""
strict-method-invocation="">
<!--该元素可以出现,也可以不出现,最多出现一次-->
<result-types>
<!--该元素必须出现,可以出现无数次-->
<result-type name="" class="" default="" default="true|false">
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</result-type>
</result-types>
<!--该元素可以出现,也可以不出现,最多出现一次-->
<interceptors>
<!--该元素的interceptor元素和interceptor-stack至少其中之一出现或者两者都出现-->
<!--下面元素可以出现0次,也可以出现无数次-->
<interceptor name="" class="">
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</interceptor>
<!--下面元素可以出现0次,也可以出现无数次-->
<intercepor-stack name="">
<!--该元素必须出现,也可以出现无数次-->
<interceptor-ref name="">
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</interceptor-ref>
</interceptor-stack>
</interceptors>
<!--下面元素可以出现0次,也可以出现无数次-->
<default-interceptor-ref name="">
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</default-interceptor-ref>
<!--下面元素可以出现0次,也可以出现无数次-->
<default-action-ref name="">
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</default-action-ref>
<!--下面元素可以出现0次,也可以出现无数次-->
<global-results>
<!--该元素必须出现,可以出现无数次-->
<result name="" type="">映射资源
<param name="参数名">参数值</param>
</result>
</global-results>
<!--下面元素可以出现0次,也可以出现无数次-->
<global-exception-mapping>
<exception-mapping name="" exception="" result="">
异常处理资源
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</exception-mapping>
</global-exception-mapping>
<action name="" class="" method="" converter="">
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
<!--下面元素可以出现0次,也可以出现无数次-->
<result type="" name="">
映射资源<param name="参数名">参数值</param>
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</result>
<!--下面元素可以出现0次,也可以出现无数次-->
<interceptor-ref name="">
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</interceptor-ref>
<!--下面元素可以出现0次,也可以出现无数次-->
<exception-mapping name="" exception="" result="">
异常处理资源
<!--下面元素可以出现0次,也可以出现无数次-->
<param name="参数名">参数值</param>
</exception-mapping>
<!--下面元素可以出现0次或者1次-->
<allow-methods></allow-methods>
</action>
</package>


</struts>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值