JSからSpring Controllerへのアイテムの配列を渡します。私はJSでこのモデルを持っている:オブジェクトの配列はAjaxのString to Springコントローラのようになります
function Row() {
this.id = 0;
this.rulingValue = '';
this.rulingType = '';
this.dateStart = '';
this.dateEnd = '';
}
私は行の配列がある - そして、私はこの配列を埋めるvar jsonData = [];
を。そして、私はList<Item>
@Data
public class Item {
private String id;
private String rulingValue;
private String rulingType;
private String dateStart;
private String dateEnd;
}
@RequestParam("items") List<Item> items
のように、この配列を期待しかし、私の項目のパラメータは文字列として到着春コントローラで
var oMyForm = new FormData();
oMyForm.append("items", jsonData);
に設定します。この配列をList<Item>
のように取得するにはどうすればよいですか?
'@ RequestBody'を使用してください。クエリ文字列の '@ RequestParam' – sura2k