我有以下代码,我将实现/ getJson将返回用户对象的功能,因为json和/ getJson2将返回user2作为Json对象.
@ParentPackage("json-default")
public class JsonAction extends ActionSupport{
private User user = new User("John","Smith");
private User user2 = new User("Smith","John");
public String populate(){
return "populate";
}
@Action(value="/getJson", results = {
@Result(name="success", type="json")})
public String test(){
return "success";
}
@Action(value="/getJson2", results = {
@Result(name="success", type="json")})
public String test2(){
return "success";
}
@JSON(name="user")
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
@JSON(name="user2")
public User getUser2() {
return user2;
}
public void setUser2(User user2) …Run Code Online (Sandbox Code Playgroud)