ajax将数组或list集合传到后台 的 【坑】
代码如下
function deleteChecked() { var orderNosList = new Array(); var rows = $("#dataGrid").datagrid("getChecked"); if (rows.length < 1) { $.messager.confirm("提醒", "请选择招聘信息!"); } else { for (var i = 0; i < rows.length; i++) { orderNosList[i] = rows[i].id; } var params = { reserveOrderNoList : orderNosList }; $.ajax({ url : '${ctx}/lf/ll_wb_job/deleteChecked', data : JSON.stringify(params), type : 'POST', contentType : "application/json", dataType : 'json', success : function() { console.log(data); } }); } }
前台页面、后台也不报错,就是获取不到
修改如下
function deleteChecked() { var rows = $("#dataGrid").datagrid("getChecked"); var ids = []; if (rows.length < 1) { $.messager.confirm("提醒", "请选择招聘信息!"); } else { for(var i=0; i<rows.length; i++){ ids[i] = rows[i].id; } alert(ids) $.ajax({ type: 'post', url: '${ctx}/lf/ll_wb_job/deleteChecked', data: {ids:ids}, traditional: true, success: function (result) { console.log(result) }, error: function(data){ alert("操作异常"); } }); } }
/** * 批量删除选中信息 */ @RequiresPermissions("lf:ll_wb_job:delete") @RequestMapping(value = "deleteChecked", method=RequestMethod.POST) @ResponseBody public Map<String, Object> deleteChecked(HttpServletRequest request, HttpServletResponse response,Model model, Long[] ids) throws Exception { Map<String, Object> jsonMap = new HashMap<String, Object>(); try{ boolean result = ll_wb_job_service.deleteChecked(ids); if (result) { jsonMap.put("success", true); jsonMap.put("msg", "操作成功"); } else { jsonMap.put("success", false); jsonMap.put("msg", "操作失败"); } }catch (Exception e) { log.error("系统异常",e); jsonMap.put("success", false); jsonMap.put("msg", "操作失败"); } return jsonMap; }
https://blog.csdn.net/qq_32786873/article/details/80280869
https://blog.csdn.net/huaieli1/article/details/56678376/
https://blog.csdn.net/zengguanlin/article/details/80067816?utm_source=blogxgwz0
请留下你的足迹...