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..

原文地址:https://www.cnblogs.com/zhukezhuke/p/2302199.html