1. 程式人生 > >controller接收列表引數,List

controller接收列表引數,List

$.ajax請求加請求頭contentType: 'application/json;charset=utf-8'

var data =[];
data.push({username: "yss"});
$.ajax({
    type: "post",
    url: "/param/map",
    data: JSON.stringify(data),
    dataType: "json",
    contentType: 'application/json;charset=utf-8',
    success: function (data) {
        console.log(data);
    }
});

controller

@PostMapping("/map")
public Object testMap(@RequestBody List<User> data) {
    return data;
}