struts2的常见配置
struts2配置文件的加载顺序:
init_DefaultProperties() ----加载default.properties
init_TraditionalXmlConfigurations(); ----加载struts-default.xml、struts-plugin.xml、struts.xml
init_LegacyiStrutsProperties(); ----加载struts.properties
init_CustomConfigurationProviders(); ----加载配置提供类
init_FilterInitParameters() ; // [6] ----加载web.xml中过滤器初始化参数
init_AliasStandardObjects() ; // [7] ----加载Bean对象
配置文件加载顺序
default.properties
struts-default.xml
struts-plugin.xml
struts.xml
struts.properties
web.xml
注意:后配置的常量的值会覆盖先配置的常量的值
action相关配置
<package name="hello" extends="struts2-default" namespace="/">
<!-- action标签的属性;
name:与namespace共同决定访问路径
class:Action类的全路径
method:执行Action中的哪个方法的方法名,默认值execute -->
<action name="hello" class="com.stu.action.HelloAction">
<!--跳转页面 -->
<result name="success">/demo1/success.isp</result>
</action>
</package>
分模块开发的配置
<include file="com/stu/action/struts1.xml"></include>
<include file="com/stu/action/struts2.xml"></include>
如有雷同或错误,欢迎联系作者,共同探讨,共同学习!