模块包含
做项目时,当Struts配置文件比较多,需要模块化划分或分开成为多个配置文件时,公共配置放在struts.xml,其余有各自的xml文件,后使用<include>标签把其它的配置文件引入到Struts.xml配置文件中就可以了。
默认Action
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" namespace="/" extends="struts-default">
<default-action-ref name="index"></default-action-ref>
<action name="index">
<result>/default.jsp</result>
</action>
</package>
</struts>
Action总结
1、实现一个action的最常用的方式:从ActionSupport继承
2、DMI动态方法调用,!
3、通配符配置*{1}{2}、、、、
4、接收参数的方法(一般用属性接收,或者DomianModel来接收)
5、简单参数验证:addFieldError
a)一般不适用struts2的UI标签
6、访问Web元素
a)Map类型
i。 IoC,这种用的多,就是继承那几个接口,
ii。依赖struts2,这种就是需要使用ActionContext来获取。
request=(Map)ActionContext.getContext().get("request");
session=(Map)ActionContext.getContext().get("session");
application=(Map)ActionContext.getContext().get("application");
b)原始类型
i。IoC
ii。依赖struts2
7、包含文件配置
8、默认action处理