struts--动态方法调用和使用通配符(8)
来源:互联网 发布:知乎英国脱欧利弊 编辑:程序博客网 时间:2024/06/06 04:14
8、为应用指定多个struts.xml文件(使用indclude)包含进来
<struts>
<include file="struts_user.xml"/>
<incllude file="struts_other.xml"/>
</struts>
配置文件包的名称要唯一
9.动态方法的调用和使用通配符定义
实现struts1中的DispathAction的效果
<action path="/control/employee/manage"
type="...DispathAction"
parameter="method"/>
struts2中的两种方式:
(1).动态方法调用
在Action名称的后面加"!"+方法名称就可以了,可以用一个常量禁止动态方法的调用
<constant name="struts.enable.Dynamic.MethodInvocation" value="false"/>
HashMap可以有Null的键和值 Hashtable不能
(2).使用通配符的方式
<package name="employee" namespace="/control/employee" extends="sstruts-default">
<action name="list_*" class="cn.itcast.action.HelloWorldAction" method="execute">
<result name="success">/WEB-INF/page/message.jsp</result>
</action>
</package>
还可以method="{1}"得到匹配的字符串
/action/employee/list_addUI.action
10.如何去接收请求参数
在struts1中通过ActionForm接收请求参数,属性和请求参数名称相同的情况下才接收,要提供
属性的set方法
在struts2中
在Action中定义与请求参数同名的属性,struts2便能够自动的接收请求参数,并赋予给同名的属性
/struts2通过反射技术调用与请求参数同名的属性和setter方法获取
在jsp页面上上得到参数要用到get方法
<form action="<%request.getContextPath()%>/control/employee/listexecute_action">
....
</form>
使用复合类型接收请求参数
id:<input type="text" name="person.id"/>
在页面上El表达式:id=${person.id}
怎样能够接收person复合类型
拦截器接收到请求参数---请求参数名称---访问对应的属性----person为null,利用
反射技术,调用默认的构造方法生成对象,通过反射技术注入值
通过doFilter来解决乱码
doFilter{
req.setCharacterEncoding("UTF-8");
filterChain.doFilter(request,response);
}
- struts--动态方法调用和使用通配符(8)
- Struts通配符和动态方法调用
- struts2中动态方法调用和使用通配符定义Action
- struts2动态方法调用和使用通配符定义action
- 动态方法调用和使用通配符定义action
- action动态方法调用和使用通配符定义action
- struct2动态方法调用和使用通配符定义action
- Struts2动态方法调用和使用通配符定义action
- 八、动态方法的调用和使用通配符定义action
- Struts2_动态方法调用和使用通配符定义action
- struts2-10动态方法调用和使用通配符定义action
- Struts2学习笔记(二) 使用通配符动态调用方法
- struts的三种动态方法调用方式,dmi,通配符
- struts2的动态方法调用(DMI)和通配符映射
- Struts2通配符和动态方法调用
- Struts2通配符和动态方法调用
- struts2-通配符和动态方法调用
- 分配模块、通配符和动态方法调用
- 虚拟机栈和本地方法栈OOM测试1
- Dev控件系列之ASPXGridview控件自主绑定数据
- gcc的常用命令行选项
- 等概率随机函数的实现
- 使用队列实现二叉树按层次遍历(C++)
- struts--动态方法调用和使用通配符(8)
- 信息论,熵
- struts---自定义类型转换器(11)
- WTL在VC各版本下的安装
- [MINA]android2.2中使用mina注意的问题
- 虚拟机安装linux后,解决屏幕不能全屏以及鼠标来回切换的方法
- 更新配置
- 笔记本键盘帽脱落解决
- struts--自定义类型转换类/注册类型转换器