NutzCN Logo
问答 json是类似map形式的,到action层不知道怎么转换成bean去接
发布于 2551天前 作者 qq_39fcc7a4 1690 次浏览 复制 上一个帖子 下一个帖子
标签:

前台传的数据格式:o: Object
prePayDetailBeans:"[
{"name":"New Row","_id":2,"_uid":2,"_state":"added","zcName":"15","je":"22","bz":"22bz"},{"name":"NewRow","_id":1,"_uid":1,"_state":"added","zcName":"15","je":"11","bz":"11bz"}
]"
title:"t1"

action接收到的json格式:
{o[title]=t1, o[prePayDetailBeans]=[{"name":"New Row","_id":2,"_uid":2,"_state":"added","zcName":"15","je":"22","bz":"22bz"},{"name":"New Row","_id":1,"_uid":1,"_state":"added","zcName":"15","je":"11","bz":"11bz"}]}

8 回复

这样写的出错了
public Object add(@Param("..") Map qm) throws Exception {
BaseResultMap ret = new BaseResultMap(true, "处理成功.");// 如果不发生异常的话,返回此消息
CwZcpdShowBean parentBean = Lang.map2Object(qm, CwZcpdShowBean.class);

获取不到值,parentBean 属性全为null

CwZcpdShowBean有什么属性

public class CwZcpdShowBean extends CwZcpdPojo {

private List<CwZcpdMxShowBean> prePayDetailBeans;

public List<CwZcpdMxShowBean> getPrePayDetailBeans() {
    return prePayDetailBeans;
}

public void setPrePayDetailBeans(List<CwZcpdMxShowBean> prePayDetailBeans) {
    this.prePayDetailBeans = prePayDetailBeans;
}

}

public class CwZcpdPojo {
@Name()
private String id;
@Column("CODE")
private Integer code;
@Column("TITLE")
private String title;
@Column("ZC_TOTAL")
private Double zcTotol;
@Column("SR_TOTAL")
private Double srTotol;
@Column("JE_TOTAL")
private Double jeTotol;
@Column("XT_DEP_ID")
private String xtDepId;
@Column("XT_DEP_NAME")
private String xtDepName;
@Column("PASSWORD")
private String password;
@Column("CREATE_TIME")
private Date createTime;
@Column("CREATE_USER_ID")
private String createUserId;
@Column("UPDATE_TIME")
private Date updateTime;
@Column("UPDATE_USER_ID")
private String updateUserId;

所以,是 o : {...} 的value才对于这个pojo咯

public Object add(@Param("..")Map, params, @Param("o")CwZcpdShowBean parentBean) throws Exception {
 BaseResultMap ret = new BaseResultMap(true, "处理成功.");// 如果不发生异常的话,返回此消息

添加回复
请先登陆
回到顶部