简体   繁体   中英

Big Json data in Java servlet

I work with java servlets and I want to receive Big json data from client.

my client code is

 url: "http://localhost:8080/JsonTest/setJson",
 type: "POST",
 dataType: 'json',
 contentType: 'application/json',
 data:{json:str},

my server code is

String json=request.getParameter("json");

but json variable is null

Can anybody help me?

try JSON.stringify on the data:

url: "http://localhost:8080/JsonTest/setJson",
type: "POST",
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify({json:str}),

or if str is already a json string:

url: "http://localhost:8080/JsonTest/setJson",
type: "POST",
dataType: 'json',
contentType: 'application/json',
data: str,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM