springmvc 多文件上传 MultipartFile 怎么获取前台传过来的参数

2024-12-02 15:11:46
推荐回答(1个)
回答1:

用@ResponseBody
@RequestMapping(value = "/address", method = RequestMethod.POST)

@ResponseBody
public Map addressPOST() {
Map map = new HashMap<>();
ReceivedGoodsAddress receivedgoodsaddress=new ReceivedGoodsAddress();
List list = addressService.findReceivedGoodsAddress(receivedgoodsaddress);
map.clear();
map.put("list", list);
return map;
}
//前台用jquery+ajax
$.ajax({
type:'POST',
url:'${contextPath}/address',
dataType:'json',
success:function(data){
$.each(data.list,function(i,item){
alert(i);
alert(item.id);
alert(item.name);
});
}
});