版权声明:欢迎转载大宇的博客,转载请注明出处: https://blog.csdn.net/yanluandai1985/article/details/84347545
先定义一个对象,对象里面拥有一个 数组属性。发送的时候,发送的是这个对象。
在后台用一个数组接收。
1. 前台写法
var data = {ids: null};
var ids = [];
selected.forEach(function (item) {
ids.push(item.id);
});
data.ids = ids
operationConfirm({
title: SAFE_SOFT_PAYROLL.operation_data_title,
text: SAFE_SOFT_PAYROLL.remove_data_read
}, function () {
debugger;
$.ajax({
url: securedroot + "notice/read",
type: "POST",
dataType: "json",
data: data,
success: function (data) {
if (data.success) {
operationSuccess();
ids = null;
$socialArchiveDataTable.bootstrapTable('refresh', {url: "yourUrl"});
}
}
});
});
2. 发送的JSON效果
3. 后台接收
@ResponseBody
@RequestMapping(value = URL_NOTICE_READ, method = {RequestMethod.POST})
public JsonResponseVO updateReadFlag(@RequestParam(value = "ids[]") Long[] ids) {
LOGGER.info("更新消息:{}",ids);
noticeService.updateReadFlag(ids);
return new JsonResponseVO();
}