前端处理,将array处理成json字符串,JSON.stringify();
let params = [{id:1,name:'ab'},{id:2,name:'cd'}]
axios(`/batch/pass`, JSON.stringify(params), {headers: {'Content-Type': 'application/json;charset=UTF-8'}});
后台接收
其中User对象对应前端传递的id和name
/**
* @description: 批量
*
* @param users
* @return xxx
* @author xxx
* @date 2019/11/26
*/
@PostMapping(value = "/batch/pass", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Booelean batchTestPass(@RequestBody List<User> users) {
return true;
}