Struts2中Action接收参数的方法

来源:互联网 发布:旋转矩阵 左手系右手系 编辑:程序博客网 时间:2024/05/14 09:46
1.使用Action的属性接收参数 : 
    a.定义:在Action类中定义属性,创建get和set方法; 
    b.接收:通过属性接收参数,如:userName(可以定义多个属性); 
    c.发送:使用属性名传递参数,如:user1!add?userName=jim;

2.使用DomainModel接收参数: 
    a.定义:定义Model类,在Action中定义Model类的对象(不需要new),创建该对象的get和set方法; 
    b.接收:通过对象的属性接收参数,如:user.getUserName(); 
    c.发送:使用对象的属性传递参数,如:user2!add?user.userName=mike; 
3.使用ModelDriven接收参数(现在用的比较多的方式): 
    a.定义:Action实现ModelDriven泛型接口,定义Model类的对象(必须new),通过getModel方法返回该对象; 
    b.接收:通过对象的属性接收参数,如:user.getUserName(); 

    c.发送:直接使用属性名传递参数,如:user2!add?userName=tom

原文链接:http://blog.csdn.net/strawhat2416/article/details/8935415

0 0
原创粉丝点击