struts 2--用DomainModel接收参数

public class UserAction{

 private User user;

public String add()

{

 System.out.println("name="+user.getName());

System.out.println("age="+user.getAge());

return SUCCESS;

}

 public User getUser()

{

 return user;

}

public void setUser(User user)

{

 this.user=user;

}

 

}

可用user!add?user.name=xx&user.age=9来调用。

 

还有一种情况是用dto对象来传递参数 newUser(userdto dto)

在user跟Userdto对不上的时候使用,比如userdto比user 多confirmpassword..

posted @ 2011-12-26 16:02  汉卿  Views(353)  Comments(0Edit  收藏  举报