码迷,mamicode.com
首页 > Web开发 > 详细

Json传递数据两种方式

时间:2018-11-28 15:48:47      阅读:911      评论:0      收藏:0      [点我收藏+]

标签:data   fail   apt   owa   tst   传递   error   erro   str   

    @PostMapping(value = "/list")
@ResponseBody
public void invoiceDetail2(String ids) {
JSONObject jsonobject = JSONObject.parseObject(ids);
JSONArray jsonArray = JSONArray.parseArray(jsonobject.get("list1").toString());
List<String> list = jsonArray.toJavaList(String.class);
}

@PostMapping(value = "/list2")
@ResponseBody
public void list2(@RequestBody ScannerVo vo) {
List<String> list = vo.getList1();
// JSONArray jsonArray = JSONArray.parseArray(vo.getList1());
// List<String> list = jsonArray.toJavaList(String.class);
}

public class ScannerVo {

private List list1;


public List getList1() {
return list1;
}

public void setList1(List list1) {
this.list1 = list1;
}

public String getTest() {
return test;
}

public void setTest(String test) {
this.test = test;
}

private String test;


}

var getInvoice = function (invoiceCode,invoiceNum) {
var list1 = ["number","name"];
var param = {};
param["list1"] = list1;
param["test"] ="java";
var json = JSON.stringify(param);
$.ajax({
type: ‘POST‘,
url: CTX + ‘/checkInvoice/list2‘,
data: json,
dataType: "json",
async:false,
contentType: ‘application/json‘,
success: function(data){
if(data.success) {
value = ‘success‘;
$("#table").bootstrapTable(‘refresh‘);
} else {
value = ‘fail‘;
}
showAlertFrame(value, data.message);
},
error: function (e) {

}
});

};



Json传递数据两种方式

标签:data   fail   apt   owa   tst   传递   error   erro   str   

原文地址:https://www.cnblogs.com/dand/p/10031854.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!