The problem now is that I can parse the data out of the servlet from the client, such as the name=www above, but the object passed in by the client
(Var j ={"name": "King", "Password": 123456}) Not in the servlet, as if to go first to the object, I think it should be,
After all, JSON provides many ways to convert the JSON data you get to another format, but it's still confusing. I am novice, the first contact, want to know the friend appointed, grateful.
For:
That's what I understand. First of all, for the JSON serialization you want to pass to the server (servlet), use Json.stringify,
Make sure that the string we pass conforms to the JSON structure, because the data we pass is passed to the server as streaming, so we should
Server-side read-in buffer in conversion string output
Public String readjsonstring (HttpServletRequest request) {
StringBuffer json = new StringBuffer ();
String line = null;
try {
BufferedReader reader = Request.getreader ();
while (line = Reader.readline ())!= null) {
Json.append (line);
}
}
catch (Exception e) {
System.out.println (E.tostring ());
}
return json.tostring ();
}
And then turn to the Jsonobject object. You can take the value.
There's one more thing to note. encoding format
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.