0
我正在從AngularJS調用一個Spring API,在那裏我試圖傳遞一個模型對象列表作爲參數。將AngularJS的列表傳遞給Spring Controller
data.append('updatedItems', $scope.QuoteList);
$http.post('updateQuotes', data).success(function(response) {
console.log(response);
});
然後在春天控制器,我想如下接收
@RequestMapping(value = "/updateQuotes", method = RequestMethod.POST)
public ArrayList<ConsumerPrice> updateQuotes(@RequestBody List<ConsumerPrice> updatedItems, ConsumerPrice consumerPrice) {
System.out.println(updatedItems);
return null;
}
在這一點上,我得到一個異常如下所述。我不確定這是否是從Angular向Spring控制器傳遞列表的正確方法。
Invalid mime type "application/json;charset=utf-8, multipart/form-data;
我在互聯網上發現了很少的指導,並嘗試像提供消費標題,但沒有任何幫助。任何指導意見將是巨大的
我想在春天控制器,但沒有幫助
我跟着一個建議並創建了一個包裝類如下所示 公共類ConsumerPriceWrapper { \t列表 listConsumerPrice; } 然後在Spring控制器中,我添加了如下但仍然不起作用 public ArrayList updateQuotes(@RequestBody ConsumerPriceWrapper updatedItems,ConsumerPrice consumerPrice) –
CrazyMac