js创建jsonArray传输至后台及后台全面解析
作者:jingxian 时间:2024-05-03 15:57:47
之前一直没弄清jsonArray和jsonObject的区别,今天终于弄明白了。
jsonArray是数组,以[ ]包含数据,jsonObject是对象,以{ }包含数据。
介绍一个在前台组建一个jsonArray的容易方法
var array=[];
for(int i=0;i<10;i++){
var item={};
item.a="a"+i;
item.b="b"+i;
array.push(item);
}
Ajax:
params:{
data:JSON.stringify(array),
type:1
}
在后台可以接收:
String data=request.getParameter("array");
JSONArray myArray=JSONArray.fromObject(data);
for(int i=0;i<myArray.size();i++){
JSONObject object=myArray.getJSONObject(i);
String a = object.getString('a');
String b = object.getString('b');
}
标签:js,jsonArray,后台
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
python实现处理Excel表格超详细系列
2021-06-22 13:34:36
![](https://img.aspxhome.com/file/2023/5/105245_0s.png)
盗亦有道 Web2.0网站优秀模仿者逐个数
2007-09-11 19:46:00
![](https://img.aspxhome.com/file/uploadpic/20079/11/2007911195132205.jpg)
python selenium中Excel数据维护指南
2021-05-29 02:52:22
![](https://img.aspxhome.com/file/2023/3/120483_0s.png)
K近邻法(KNN)相关知识总结以及如何用python实现
2022-07-15 17:10:45
![](https://img.aspxhome.com/file/2023/9/70099_0s.png)
Request.ServerVariables各参数说明集合
2008-11-25 18:49:00
Python openpyxl模块实现excel读写操作
2023-07-17 20:15:25
![](https://img.aspxhome.com/file/2023/6/84876_0s.png)
详解Python对某地区二手房房价数据分析
2022-04-07 04:47:30
![](https://img.aspxhome.com/file/2023/6/118766_0s.jpg)
python如何实现代码检查
2022-07-22 18:19:12
Python爬虫实战之用selenium爬取某旅游网站
2021-03-25 10:28:36
![](https://img.aspxhome.com/file/2023/4/72724_0s.png)
Python类的定义和使用详情
2021-03-10 18:10:59
![](https://img.aspxhome.com/file/2023/5/118735_0s.png)
Go1.18新特性使用Generics泛型进行流式处理
2024-02-17 07:12:42
一文详解Golang中net/http包的实现原理
2024-05-28 15:23:08
![](https://img.aspxhome.com/file/2023/8/123888_0s.png)
go日志库logrus的安装及快速使用
2024-04-26 17:31:40
python3爬虫中引用Queue的实例讲解
2023-07-15 19:43:48
vue 过滤、模糊查询及计算属性 computed详解
2024-05-09 09:53:30
![](https://img.aspxhome.com/file/2023/1/127161_0s.png)
一个滑动展示的小代码
2011-07-01 12:58:05
Python开发之迭代器&生成器的实战案例分享
2021-03-18 17:34:33
分享SQL Server删除重复行的6个方法
2011-09-30 11:33:05
使用sysbench来测试MySQL性能的详细教程
2024-01-14 14:33:54
在Python中使用元类的教程
2021-04-12 05:09:34