1. 程式人生 > >ajax解決傳遞陣列的問題

ajax解決傳遞陣列的問題

前端程式碼:

$.ajax({
	   type: "POST",
	   url: "../station/refreshGunInfo",
	   data: {gunLists:gunNumA},
	   traditional: true,  //解決傳遞陣列的問題
	   async: false,
	   dataType: 'json',
	   success: function(result){
		   if(result.status == 'SUCCESS'){
			   gunList=result.data;
		   }
	   }
	});

後端程式碼:

@RequestMapping("refreshGunInfo")
	@ResponseBody
	public List<PileChargeInfoVO> refreshGunInfo(String[] gunLists) {
		if(gunLists == null || gunLists.length == 0){
			return new ArrayList<>();
		}
}