可以只有一个web.xml,其余都是可选的。
File | Optional | Location (relative to webapp) | Purpose |
---|---|---|---|
web.xml | no | /WEB-INF/ | Web deployment descriptor to include all necessary framework components |
struts.xml | yes | /WEB-INF/classes/ | Main configuration, contains result/view types, action mappings, interceptors, and so forth |
struts.properties | yes | /WEB-INF/classes/ | Framework properties |
struts-default.xml | yes | /WEB-INF/lib/struts2-core.jar | Default configuration provided by Struts |
struts-default.vm | yes | /WEB-INF/classes/ | Default macros referenced by velocity.properties |
struts-plugin.xml | yes | At the root of a plugin JAR | Optional configuration files for Plugins in the same format as struts.xml. |
velocity.properties | yes | /WEB-INF/classes/ | Override the default Velocity configuration |
web.xml
配置文件可以自动重载,需要在struts.properties中配置。但是,会有轻微的性能损失
struts.configuration.xml.reload=true |
struts.xml
可以分割成多个文件片段,如下:
<struts> <include file="struts-default.xml"/> <include file="config-browser.xml"/> <package name="default" extends="struts-default"> .... </package> <include file="other.xml"/> </struts>
struts-plugin.xml的格式和struts.xml相同