Recently ran spring MVC with jetty to receive the POST request (the data in the post is very large). There is an issue where data cannot be obtained. Such as:
@RequestMapping (value = "/receive", method = requestmethod.post) Public
Where a is obtained from post, before the amount of data is small, it can be taken without problems.
Using the grab Bag tool, we found that the post data was not finished and the HTTP returned. This is weird.
Adjust the following parameter values:
<Setname= "Outputbuffersize">< Propertyname= "Jetty.output.buffer.size"default= "32768" /></Set> <Setname= "Requestheadersize">< Propertyname= "Jetty.request.header.size"default= "8192" /></Set> <Setname= "Responseheadersize">< Propertyname= "Jetty.response.header.size"default= "8192" /></Set> <Setname= "Headercachesize">512</Set>
Changed a lot, 10 times times the increase, the results too much data is not reported, but still do not take the parameters. It's very big and there's a memory overflow, and it's going to have to be small. Other parameters, such as the number of threads.
Change the way modify Content-type to application/x-www-form-urlencoded or multipart/form-data, just as no effect.
After trying multiple ways, using @requestbody to annotate a, the result is successful. And you do not need to adjust the jetty parameters.
Why use @requestbody?
@RequestBody
Role:
- This annotation is used to read the body portion of the request requests, parse using the system default configuration Httpmessageconverter, and then bind the corresponding data to the object to be returned;
- The object data returned by the Httpmessageconverter is then bound to the parameters of the method in the controller.
Use time:
A) GET, post method, according to the request Header Content-type value to determine:
- application/x-www-form-urlencoded, Optional (that is, not necessary, because the data of this situation @requestparam, @ModelAttribute can also be processed, of course @requestbody can also handle);
- Multipart/form-data, cannot be processed (i.e. using @requestbody cannot process data in this format);
- Other formats must be (other formats include Application/json, Application/xml, etc.). Data in these formats must be handled using @requestbody);
B) When put is submitted, it is judged according to the value of the request Header Content-type:
- Application/x-www-form-urlencoded, must;
- Multipart/form-data, unable to deal with;
- Other formats, must;
Description: The data encoding format of the body part of request is specified by the Content-type of the header section;
Reference:
http://blog.csdn.net/arsenal04/article/details/41484685 (the above content transferred from this article, first record first, to be resolved)
Https://stackoverflow.com/questions/29527803/eliminating-or-understanding-jetty-9s-illegalstateexception-too-much-data-aft
Jetty Error: BadMessage:java.lang.IllegalStateException:too much data after closed for [email protected]{r=2,c= false,a=idle,uri=}