【2】Struts2的常见配置
2016-11-26 10:54
330 查看
1、Struts2的配置文件的加载顺序
init_DefaultProperties(); // [1] -----default.propertiesinit_TraditionalXmlConfigurations(); // [2] -----struts-default.xml,struts-plugin.xml,struts.xml
init_LegacyStrutsProperties(); // [3] -----struts.properties
init_CustomConfigurationProviders(); // [5] -----客户自定义提供类
init_FilterInitParameters() ; // [6] -----加载web.xml中过滤器中的参数
init_AliasStandardObjects() ; // [7] -----加载自定义类
这几个值定义了Struts2的配置文件的加载顺序:
default.properties
struts-default.xml
struts-plugin.xml
struts.xml
struts.properties
web.xml
2、包的配置(package)
Struts2为了更好管理Action,将Action分包进行管理的。l <package>包中的顺序
n name :包名,一个配置文件中不要出现重复的包名。
n extends :继承其他的包,通常继承struts-default.
n namespace :名称空间,与<action>中的name属性共同决定访问路径。
u namespace=”/”
u namespace=””
u namespace=”/aaa”
n abstract :如果设置为true,就可以应用于其他包的继承。
3、Action的配置
l <action>中的配置n name :与名称空间共同决定访问路径
n class :Action类的全路径
n method :Action中要执行的方法的名称,默认值execute.
4、常量的配置
Struts2中常量有三个配置的位置:
l struts.xml(推荐)
<constant name="struts.action.extension" value="action"/>
l struts.properties
struts.action.extension=action
l web.xml
<!-- 配置Struts2的核心过滤器:前端控制器(完成部分功能) -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>struts.action.extension</param-name>
<param-value>action</param-value>
</init-param>
</filter>
*****后加载配置文件常量的值会覆盖先加载的配置文件中常量的值。
相关文章推荐
- struts2 convention配置中常见配置选项及说明
- struts2配置常见异常
- Struts2 - 02 配置文件及常见标签
- 配置STRUTS2的几个常见错误1
- Struts2的常见的配置文件介绍
- Struts2的常见的配置文件介绍
- struts2 convention配置中常见配置选项及说明
- 【笔记】struts2学习笔记(二)--常见问题/一些配置/Myeclipse使用
- struts2配置常见异常
- Struts2常见的常量配置
- struts2配置基础和常见错误
- struts2配置常见异常
- struts2 struts.xml配置中常见配置选项及说明
- struts2常见配置
- [struts2]struts2的validation.xml配置不起作用的常见原因
- struts2常见配置解决错误There is no mapped for namespace[/] and action name
- Struts2初学者常见配置问题
- Struts2中result配置中常见的几种视图转发类型
- struts2 配置常见问题
- struts2 convention配置中常见配置选项及说明