第一种:Action的属性接收参数
public class UserAction extends ActionSupport {
private String name;
private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
第二种:DomainModel接收参数, 一般项目都用这种
public class UserAction extends ActionSupport {
private User user;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
第三种:ModelDriven接收参数,实现接口,实现抽象方法.不用写了get/set
public class UserAction extends ActionSupport implements ModelDriven<User>{
private User user = new User();
@Override
public User getModel() {
return user;
}
}