ajax前台提交数据,Json数据在java后台怎么取出来

2024-10-27 23:35:48
推荐回答(2个)
回答1:

json数据的话,在后台,你可以定义好实体类型,然后来进行转换,有名的转换工具是fastjson,可以转成java对象,list对象等等各种复杂的

回答2:

//拼装JSON格式数据json
var json={"edit":[{"bh":"11111","mc":"11111","dbms":"ORACLE9i","dwmmc":"","addr":"","username":"","password":"","rm_sz":"ck","nyr_sz":"","id":"-1"},{"bh":"121","mc":"12","dbms":"ORACLE9i","dwmmc":"12","addr":"12","username":"12","password":"12","rm_sz":"ck","nyr_sz":"2011-09-06","id":"13"}],"del":["12"]};
var post={data:JSON.stringify(json)};//JSON.stringify(json)把json转化成字符串
$.post(url,post);
……
后台简要代码:
……
JSONObject json=JSONObject.fromObject(request.getParameter("data"));
List> edit=(List>) json.getJSONArray("edit");
List del=(List) json.getJSONArray("del");
//下面的操作就