把struts2的struts.xml配置文件分解成多个配置文件
在默认的情况下,Struts只自动加载路径下的struts.xml,default-struts.xml和struts-plugin.xml三类文件。但是随着应用的增大,系统中Action数量也增大,将导致struts.xml变得非常的臃肿。
为了避免struts.xml文件过于庞大,提高struts.xml的可读性,我们可以将一个struts.xml配置文件分解成多个的配置文件,然后再struts.xml文件中包含其他的配置信息。
例如:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<include file="struts-part1.xml"/>
<include file="struts-part2.xml"/>
<include file="struts-part3.xml"/>
...
</struts>
上面的的
<include file="struts-part1.xml"/>
<include file="struts-part2.xml"/>
<include file="struts-part3.xml"/>
使用的include包含了其他的配置文件。通过这种方式,struts2能以一种模块化的方式来管理。
说明:
被包含进去的文件是标准的struts2的配置文件,一样包含了DTD信息,Struts2配置文件跟元素等信息。把struts2的struts.xml配置文件分解成多个配置文件
原文:http://blog.csdn.net/qq_20545159/article/details/44653651