<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!--
constant:配置常量
* name:指定的是struts2框架底层提供的default.properties资源文件中配置的"常量"
* value:指定的是配置常量的值
* 在struts.xml文件中,配置的常量的值会覆盖底层提供的default.properties资源文件中配置的常量的值
* 配置struts2框架的页面中请求链接的后缀名,若是指定多个的话,用","隔开
* 若是在struts.xml中和struts.properties资源文件中同时进行配置,struts.properties的配置起做用
* 由于常量能够在多个配置文件中进行定义,因此咱们须要了解下struts2加载常量的搜索顺序:
1 struts-default.xml
2 struts-plugin.xml
3 struts.xml
4 struts.properties(本身建立)
5 web.xml
-->
<!-- <constant name="struts.action.extension" value="do,love"></constant> -->
<!-- 配置国际化资源文件修改时,是否从新加载。默认是false为不加载,true是加载 -->
<!-- <constant name="struts.i18n.reload" value="true"></constant> -->
<!-- 配置struts2框架的配置文件修改时,是否从新加载。默认是false为不加载,true是加载 -->
<!-- <constant name="struts.configuration.xml.reload" value="true"></constant> -->
<!--
配置struts2框架的模式
* 默认值是false,是生产模式
* true是开发模式,须要更多的调试信息
### includes:
### - struts.i18n.reload = true
### - struts.configuration.xml.reload = true
-->
<constant name="struts.devMode" value="true"></constant>
<!-- 配置动态方法调用,设置成不开启。默认是true是开启状态;false是不开启状态 -->
<constant name="struts.enable.DynamicMethodInvocation" value="false"></constant>
<!--
配置全部资源文件,省略后缀名,若是配置多个资源文件时,用","隔开。不只是国际化资源文件
* 类型转换器的错误提示资源文件
* 国际化资源文件
* 上传文件的错误提示信息资源文件
-->
<constant name="struts.custom.i18n.resources"
value="cn.itcast.converter.converter,
cn.itcast.i18n.resources,
cn.itcast.upload.fileuploadmessage,
cn.itcast.ognl.resources">
</constant>
<!-- 配置文件上传的总大小 -->
<constant name="struts.multipart.maxSize" value="2097152000"></constant>
<!-- 引入自定义配置文件 -->
<include file="cn/itcast/primer/struts_primer.xml"></include>
<include file="cn/itcast/resulttype/struts_resulttype.xml"></include>
<include file="cn/itcast/pattern/struts_pattern.xml"></include>
<include file="cn/itcast/converter/struts_converter.xml"></include>
<include file="cn/itcast/context/struts_context.xml"></include>
<include file="cn/itcast/i18n/struts_i18n.xml"></include>
<include file="cn/itcast/upload/struts_upload.xml"></include>
<include file="cn/itcast/aop/struts_aop.xml"></include>
<include file="cn/itcast/validate/struts_validate.xml"></include>
<include file="cn/itcast/ognl/struts_ognl.xml"></include>
</struts>web
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- /primer/helloWorldAction.action
package:包
* name:包名,惟一的,必选项
* namespace:命名空间,惟一的,至关于房间号。可选项,省略状况下是"/"。页面中请求链接的前半部分
* extends:继承
* extends="struts-default":struts2框架底层提供的核心包struts2-core-2.3.3.jar下的struts-default.xml文件
* 为何要继承这个struts-default.xml文件?
* 由于struts2框架底层提供的struts-default.xml声明了全部的拦截器和拦截器栈,
知道在struts2框架运行时执行struts-default.xml文件中的拦截器栈。
* 若是不继承struts-default.xml文件,就没有办法使用struts2框架提供的全部拦截器
-->
<package name="primer" namespace="/primer" extends="struts-default">
<!--
若是找不到对应的action名的时候,配置默认要执行的action
* name:指定action的名称
-->
<default-action-ref name="helloWorldAction" />
<!--
action:
* name:对应页面中请求链接的后面半部分
* class:对应要执行的类的完整路径
-->
<action name="helloWorldAction" class="cn.itcast.primer.HelloWorldAction">
<!--
result:结果类型
* name:对应的是执行的类的方法的返回值
public String execute() throws Exception {
System.out.println("HelloWorldAction ************* execute()");
return "success";
}
* 后半部分的文本内容:要转向到的页面
-->
<result name="success">/primer/success.jsp</result>
</action>
<!--
没有为action指定class
* 在struts2框架底层的struts-default.xml文件中,配置了默认执行的类
com.opensymphony.xwork2.ActionSupport
public String execute() throws Exception {
return SUCCESS;
}
* 实际上,默认执行的是底层提供的ActionSupport类的execute()方法
* result结果类型,默认是根据struts2框架底层提供的ActionSupport类的execute()方法返回值,进行跳转
-->
<action name="actionNoClass">
<result name="success">/primer/success.jsp</result>
</action>
</package>
</struts>apache