其他分享
首页 > 其他分享> > ajax传输数组类型的参数

ajax传输数组类型的参数

作者:互联网

$.ajax({
               type:"post",
               traditional: true,
               data:{arr:arr},
               url:"${pageContext.request.contextPath}/customer/deleteById",
               dataType:"json",
               success: function (msg) {
                 if(msg.code==200){
                     window.location.href="${pageContext.request.contextPath}/customer/findAll";
                 }else{
                     alert("删除失败");
                     window.location.href="${pageContext.request.contextPath}/customer/findAll";
                 }


               }


控制层代码:
@RequestMapping("deleteById")
    @ResponseBody
    public Map<String ,Object> deleteById(String [] arr){
        Map<String,Object> map=new HashMap<>();
        boolean b= customerService.deleteById(arr);
        if(b){
            map.put("code",200);
        }else {
            map.put("code",500);
        }
       return map;
    }

标签:customer,map,arr,deleteById,contextPath,传输,ajax,code,数组
来源: https://www.cnblogs.com/ych961107/p/12022973.html