400 Bad request on Spring Jquery Ajax Post

青春壹個敷衍的年華 提交于 2019-11-29 02:16:10

You are posting JSON, not form data, but you are trying to read the ArrayList<Keys> as a form parameter.

Try changing your method signature from:

public ResponseEntity<String> addKeys(@RequestParam(value="keys") ArrayList<Keys> keys){

to

public ResponseEntity<String> addKeys(@RequestBody Keys[] keys){

That may not work since your JSON has an object that has a keys property that is the list of keys. So you could try to change your ajax post data to something like

data: JSON.stringify(tmpList)

so that you are just posting the list instead of wrapping it in another object that has the keys element.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!