完整的struts.xml示范

文件示范。

<?xml version="1.0" encoding="GBK"?>

<!-- 下面指定Struts 2配置文件的DTD信息 -->

<!DOCTYPE struts PUBLIC

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

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

<!-- strutsStruts 2配置文件的根元素 -->

<struts>

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

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

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

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

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

                                 <include file="" />

                                 <!-- package元素是Struts配置文件的核心,该元素可以出现0次,或者无限多次 -->

                                 <package name="必填的包名" extends="" namespace="" abstract=""

                                    externalReferenceResolver>

                                    <!-- 该元素可以出现,也可以不出现,最多出现一次 -->

                                    <result-types>

                                        <!-- 该元素必须出现,可以出现无限多次-->

                                        <result-type name="" class="" 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次,也可以无限多次 -->

                                        <interceptor-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="">

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

                                            映射资源

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

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

                                        </result>

                                    </global-results>

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

                                    <global-exception-mappings>

                                        <!-- 该元素必须出现,可以出现无限多次-->

                                        <exception-mapping name="" exception="" result="">

                                            异常处理资源

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

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

                                        </exception-mapping>

                                    </global-exception-mappings>

                                    <action name="" class="" method="" converter="">

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

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

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

                                        <result name="" type="">

                                            映射资源

                                            <!-- 下面元素可以出现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>

                                    </action>

                                 </package>*

<struts>

你可能感兴趣的:(apache,bean,xml,struts)