ajax前台提交数据,Json数据在java后台怎么取出来
2个回答
展开全部
json数据的话,在后台,你可以定义好实体类型,然后来进行转换,有名的转换工具是fastjson,可以转成java对象,list对象等等各种复杂的
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
//拼装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<Map<String,String>> edit=(List<Map<String, String>>) json.getJSONArray("edit");
List<?> del=(List<?>) json.getJSONArray("del");
//下面的操作就
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<Map<String,String>> edit=(List<Map<String, String>>) json.getJSONArray("edit");
List<?> del=(List<?>) json.getJSONArray("del");
//下面的操作就
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询