angular.js - How to parse angular's Ajax request in the background?
PHPz2017-05-15 16:50:07
0
3
923
The data sent by angular’s Ajax request is
Object {Account: "123", Password: "123"}
How to parse and read in JAVA background? Ordinary methods will not work...
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?
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.
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/
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?
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.