我的目標是info
Angularjs:傳遞對象到Java API
info Date: "" ids: Array[1] __proto__: Object
它擁有所有的價值觀和我的角度發送。 在Java端,如果輸入的參數是一樣
public ResponseEntity<Boolean> update(@RequestBody myObject input) {...}
我得到一個錯誤:400(壞請求) HTTP Status 400 - type Status report message description The request sent by the client was syntactically incorrect.
但是,如果在API我做
public ResponseEntity<Boolean> update(@RequestBody String input) {...}
它的工作原理精細!它有什麼問題? myObject確實只有
String Date;
String[] ids;
正如伊恩所說,你必須將JSON字符串反序列化爲一個Object。這裏有一個帖子,涵蓋了幾個選擇這樣做:http://stackoverflow.com/questions/1395551/convert-a-json-string-to-object-in-java – rob