angular的Ajax请求发送的数据是
Object {Account: "123", Password: "123"}
怎么在JAVA后台解析读取?普通方法不行...
黄舟2017-05-15 16:52:07
If it is json, read it as a stream and parse it into a json object
If it is a key value pair, use querystring/form to get the value based on the key
key value pair : http://stackoverflow.com/questions/11442632/how-can-i-post-data-as-form-data-instead-of-a-request-payload
parse json : http://vitalflux.com/angularjs-post-json-data-using-ajax-springmvc/
我想大声告诉你2017-05-15 16:52:07
Since the background MVC cannot parse the value
Try using request.getParameter("pName")
in the most common servlet class to see if you can get it?
If you can get it using the servlet class
It should just be a configuration problem when using that MVC framework,
If even the servlet class cannot get the parameters, use the browser's developer tools to check whether the ajax request was sent successfully
Or is it a problem like whether the sent data turns into a string?
世界只因有你2017-05-15 16:52:07
I use angularjs in the frontend and springmvc in the backend. When the frontend makes a request to the backend, it uses JSON.stringify(data), and the backend controller uses (@RequestBody User user) to receive parameters.