完整的struts.xml文件骨架

完整的struts.xml文件模版

  1. struts.xml当然是整个struts 2 框架的整个核心,以下是一份完整的struts.xml骨架:
  2. <?xml version=”1.0″ encoding=”GBK”?>
  3. <!– 下面指定Struts 2配置文件的DTD信息–>
  4. <!DOCTYPE struts PUBLIC
  5.         “-//Apache Software Foundation//DTD Struts Configuration 2.0//EN”
  6.         “http://struts.apache.org/dtds/struts-2.0.dtd”>
  7. <!– struts是Struts 2配置文件的根元素–>
  8. <struts>
  9.                                 <!– 下面元素可以出现0次,也可以无限多次–>
  10.                                 <constant name=”” value=””/>
  11.                                 <!– 下面元素可以出现0次,也可以无限多次–>
  12.                                 <bean type=”” name=”” class=”” scope=”” static=”” optional=””/>
  13.                                 <!– 下面元素可以出现0次,也可以无限多次–>
  14.                                 <include file=””/>
  15.                                 <!– package元素是Struts配置文件的核心,该元素可以出现0次,或者无限多次–>
  16.                                 <package name=”必填的包名” extends=”” namespace=”” abstract=””
  17.                                     externalReferenceResolver>
  18.                                    <!– 该元素可以出现,也可以不出现,最多出现一次–>
  19.                                    <result-types>
  20.                                        <!– 该元素必须出现,可以出现无限多次–>
  21.                                        <result-type name=”” class=”” default=”true|false”>
  22.                                            <!– 下面元素可以出现0次,也可以无限多次–>
  23.                                            <param name=”参数名”>参数值</param>*
  24.                                        </result-type>
  25.                                    </result-types>
  26.                                    <!– 该元素可以出现,也可以不出现,最多出现一次–>
  27.                                    <interceptors>
  28.                                        <!– 该元素的interceptor元素和interceptor-stack至少出现其中之一,
  29.                                         也可以二者都出现–>
  30.                                        <!– 下面元素可以出现0次,也可以无限多次–>
  31.                                        <interceptor name=”” class=””>
  32.                                            <!– 下面元素可以出现0次,也可以无限多次–>
  33.                                            <param name=”参数名”>参数值</param>*
  34.                                        </interceptor>
  35.                                        <!– 下面元素可以出现0次,也可以无限多次–>
  36.                                        <interceptor-stacknameinterceptor-stackname=””>
  37.                                            <!– 该元素必须出现,可以出现无限多次–>
  38.                                            <interceptor-refnameinterceptor-refname=””>
  39.                                                <!– 下面元素可以出现0次,也可以无限多次–>
  40.                                                <param name=”参数名”>参数值</param>*
  41.                                            </interceptor-ref>
  42.                                        </interceptor-stack>
  43.                                    </interceptors>
  44.                                    <!– 下面元素可以出现0次,也可以无限多次–>
  45.                                    <default-interceptor-refnamedefault-interceptor-refname=””>
  46.                                        <!– 下面元素可以出现0次,也可以无限多次–>
  47.                                        <param name=”参数名”>参数值</param>
  48.                                    </default-interceptor-ref>
  49.                                    <!– 下面元素可以出现0次,也可以无限多次–>
  50.                                    <default-action-refnamedefault-action-refname=””>
  51.                                        <!– 下面元素可以出现0次,也可以无限多次–>
  52.                                        <param name=”参数名”>参数值</param>*
  53.                                    </default-action-ref>?
  54.                                    <!– 下面元素可以出现0次,也可以无限多次–>
  55.                                    <global-results>
  56.                                        <!– 该元素必须出现,可以出现无限多次–>
  57.                                        <result name=”” type=””>
  58.                                            <!– 该字符串内容可以出现0次或多次–>
  59.                                             映射资源
  60.                                            <!– 下面元素可以出现0次,也可以无限多次–>
  61.                                            <param name=”参数名”>参数值</param>*
  62.                                        </result>
  63.                                    </global-results>
  64.                                    <!– 下面元素可以出现0次,也可以无限多次–>
  65.                                    <global-exception-mappings>
  66.                                        <!– 该元素必须出现,可以出现无限多次–>
  67.                                        <exception-mappingnameexception-mappingname=”” exception=”” result=””>
  68.                                             异常处理资源
  69.                                            <!– 下面元素可以出现0次,也可以无限多次–>
  70.                                            <param name=”参数名”>参数值</param>*
  71.                                        </exception-mapping>
  72.                                    </global-exception-mappings>
  73.                                    <action name=”” class=”” method=”” converter=””>
  74.                                        <!– 下面元素可以出现0次,也可以无限多次–>
  75.                                        <param name=”参数名”>参数值</param>*
  76.                                        <!– 下面元素可以出现0次,也可以无限多次–>
  77.                                        <result name=”” type=””>
  78.                                             映射资源
  79.                                            <!– 下面元素可以出现0次,也可以无限多次–>
  80.                                            <param name=”参数名”>参数值</param>*
  81.                                        </result>
  82.                                        <!– 下面元素可以出现0次,也可以无限多次–>
  83.                                        <interceptor-refnameinterceptor-refname=””>
  84.                                            <!– 下面元素可以出现0次,也可以无限多次–>
  85.                                            <param name=”参数名”>参数值</param>*
  86.                                        </interceptor-ref>
  87.                                        <!– 下面元素可以出现0次,也可以无限多次–>
  88.                                        <exception-mappingnameexception-mappingname=”” exception=”” result=””>
  89.                                             异常处理资源
  90.                                            <!– 下面元素可以出现0次,也可以无限多次–>
  91.                                            <param name=”参数名”>参数值</param>*
  92.                                        </exception-mapping>
  93.                                    </action>
  94.                                 </package>*
  95. <struts>

标签