相关疑难解决方法(0)

Struts 2中的Json插件问题

我有以下代码,我将实现/ 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)

java ajax json struts2

8
推荐指数
1
解决办法
7897
查看次数

标签 统计

ajax ×1

java ×1

json ×1

struts2 ×1