User.java
public class User {
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;
}
}
UserAction.java
import com.opensymphony.xwork2.ActionSupport;
public class UserAction extends ActionSupport {
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;
}
}
测试连接
http://localhost:8080/Struts2/user/user!add?user.name=aaa&user.age=99