需要添加 traditional:true,//传数组 防止深度序列化 这句,否则String[] areaIds 接收一直是NULL。 js: function showLine(chartId,type,areaIds) { //console.log("showLine"+areaIds); var myChart = echarts.init(document.getElementById(chartId)); $.ajax({ url: basePath + '/getCompareLine', data:{ type : type, begDate : begDate, endDate : endDate, areaIds : areaIds }, traditional:true,//传数组 防止深度序列化 type: 'post', dataType: 'json', success: function(data) { console.log(data); myChart.setOption(data); } }); }
controller层:
@RequestMapping(value = "/getCompareLine",produces="text/html;charset=UTF-8")
@ResponseBody
public String getCompareLine(
@RequestParam(name = "type", required = false) String type,
@RequestParam(name = "begDate", required = false) String begDate,
@RequestParam(name = "endDate", required = false) String endDate,
@RequestParam(name = "areaIds", required = false) String[] areaIds) {
}