ajax transmission array type parameters

$.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 ( "Delete failed" );
                     window.location.href="${pageContext.request.contextPath}/customer/findAll";
                 }


               }


Code control layer:
@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;
    }

Guess you like

Origin www.cnblogs.com/ych961107/p/12022973.html