1.get方法接收
- 前端传参
axios会对url的参数进行encodeURIComponent编码,编码后传递的数组将对"["、"]"符号进行转码;
let a = [1]
let b = JSON.stringify(a) // '[1]'
let c = encodeURIComponent(b) // '%5B1%5D'
@GetMapping("list")
public AjaxResult getList(Vo vo) {
List<Map> list = iEventService.search(vo);
return AjaxResult.success(list);
}
@Data
public class Vo{
private List<Integer> status; //数组类型
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
private String eventType;
}
2.post方法接收
@PostMapping("list")
public AjaxResult list(@RequestBody Vo vo) {
List<Map> list = iEventService.search(vo);
return AjaxResult.success(list);
}