首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

action返回json奇怪啊解决办法

2012-01-06 
action返回json奇怪啊。。。。Action:Java codepackage com.xxb.assetsmanage.actionimport java.util.Listi

action返回json奇怪啊。。。。
Action:

Java code
package com.xxb.assetsmanage.action;import java.util.List;import javax.annotation.Resource;import org.springframework.stereotype.Component;import com.opensymphony.xwork2.ActionSupport;import com.opensymphony.xwork2.ModelDriven;import com.xxb.assetsmanage.model.User;import com.xxb.assetsmanage.service.UserService;@Component("userAction")public class UserAction extends ActionSupport implements ModelDriven<User> {    private boolean success;    private User user;    private UserService userService;    public boolean isSuccess() {        return success;    }    public void setSuccess(boolean success) {        this.success = success;    }    public User getUser() {        return user;    }    public void setUser(User user) {        this.user = user;    }    public UserService getUserService() {        return userService;    }    @Resource    public void setUserService(UserService userService) {        this.userService = userService;    }    public User getModel() {        return user;    }    @Override    public String execute() throws Exception {        List<User> users = userService.isLogin(user);        System.out.println(users.size());        if (users.size() > 0) {            success = true;        } else {            success = false;        }        return SUCCESS;    }    public String add(User user) {        userService.add(user);        return "addsuccess";    }    public String del(User user) {        userService.del(user);        return "delsuccess";    }    public String mod(User user) {        userService.mod(user);        return "modsuccess";    }}实体类package com.xxb.assetsmanage.model;import java.util.HashSet;import java.util.Set;import javax.persistence.CascadeType;import javax.persistence.Entity;import javax.persistence.GeneratedValue;import javax.persistence.Id;import javax.persistence.ManyToOne;import javax.persistence.OneToMany;import javax.persistence.Table;@Entity@Table(name="t_user")public class User {    private int id;    private String name;    private String password;    private Set<Assets> assetses = new HashSet<Assets>();    @OneToMany(mappedBy="user",cascade={CascadeType.ALL})    public Set<Assets> getAssetses() {        return assetses;    }    public void setAssetses(Set<Assets> assetses) {        this.assetses = assetses;    }    @Id    @GeneratedValue    public int getId() {        return id;    }    public void setId(int id) {        this.id = id;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public String getPassword() {        return password;    }    public void setPassword(String password) {        this.password = password;    }    }


XML code
<package name="listjson" extends="json-default">        <action name="projectjson" class="projectListAction">            <result type="json">                <param name="includeProperties">                    success,                    totalSize,                    projects\[\d+\]\.id,                    projects\[\d+\]\.name                  </param>            </result>        </action>        <action name="useraction" class="userAction">            <result type="json">                <param name="includeProperties">                    success                  </param>            </result>        </action>


我用 http://localhost:8080/AssetsProject/useraction?user.name=wangwei&user.password=pass 访问


第一次 返回 {"success":true}
再访问,就什么都没有了,返回个{}

请问这个为什么啊???

[解决办法]
楼主好人,,前来接分啦,,呵呵。。

不过,你可以把你怎么弄的共享下的啦,,HOHO
[解决办法]
提示恢复内容太短了
[解决办法]
搞好了分享经验也不错,接分。
[解决办法]
前来接分。
[解决办法]
前来接分
[解决办法]
LZ还没醒。

[解决办法]
晕 呵呵
[解决办法]

探讨
搞好了,白送分,要的来了

[解决办法]
探讨
搞好了,白送分,要的来了

[解决办法]
lz分享下经验也挺好的,来接分啦。
[解决办法]
探讨

lz分享下经验也挺好的,来接分啦。

[解决办法]
楼主好人啊,来接分啊

热点排行