atq

导航

统计
 
点击查看代码
数组名+[]的方式,可以传递数组,表单中所有的数组项可以用相同的name,serializeJSON会识别他们并放到一个数组里。

<input type="text" name="employees[]"/>
接收时,可以在bean中使用 private String[] employees; 进行接收。
 $.ajax({
            type: 'POST',
            url: '。。。',
            data: $('#form').serializeJSON(),
            success: function (json) {
            }
        });


对象数组可以用<input type="text" name="employees[][id]"/>
接收时,可以在bean中使用 private Employee[] employees; 进行接收。


后台接收还有两种方式
<input name="idList" /><input name="idList" />
public ResponseTemplate deleteUser(@RequestParam("idList") List<Long> idList) {
	...  
}

json数组 :[{id:1,name:a},{id:2,name:b}]
public ResponseTemplate updatePositionPriority(@RequestBody List<Position> positions) {
	...
}
posted on   atq  阅读(284)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
 
点击右上角即可分享
微信分享提示