Reputation: 12026
The following code works 90% of the time on normal-length JSON strings. I receive an incoming JSON String in my SpringMVC Controller, formed from a DataTable .data()
.
Ajax:
function exportParticipants() {
var table = $('#participantsTable').DataTable();
var displayData = table.rows({filter:'applied'}).data(); // Get my data into "result" array
var result = $.makeArray();
$.each(displayData,function(index,row) {
result.push(row);
});
$.ajax({
url: "/app/loadParticipantsExportValues",
type: "post",
data: {
'participants': JSON.stringify(result) // Note that I form this 'participants' param
},
success: function (res){
console.log("success");
},
error: function(jqXHR, textStatus, errorThrown) {
console.log("error");
}
Controller:
@RequestMapping(value="/loadParticipantsExportValues", method=RequestMethod.POST)
public void loadParticipantsExportValues(@RequestParam("participants") String json) throws Exception {
//...
}
But on very large JSON strings only (formed from a 10K-row DataTable), even though I verify in the Debugger that the array gets created, I get this:
org.springframework.web.bind.MissingServletRequestParameterException: Required String parameter 'participants' is not present
at org.springframework.web.method.annotation.RequestParamMethodArgumentResolver.handleMissingValue(RequestParamMethodArgumentResolver.java:204)
at org.springframework.web.method.annotation.AbstractNamedValueMethodArgumentResolver.resolveArgument(AbstractNamedValueMethodArgumentResolver.java:112)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:124)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161)
Any ideas? Is something getting truncated or maxed out?
Upvotes: 0
Views: 625
Reputation: 12026
I solved it. It was a Tomcat maxPostSize
issue, the default value is 2MB.
Example of what fixed it, server.xml in Tomcat:
<Connector port="8009" maxPostSize="4000000" protocol="AJP/1.3" redirectPort="8443"/>
or, unlimited:
<Connector port="8009" maxPostSize="-1" protocol="AJP/1.3" redirectPort="8443"/>
See also: https://stackoverflow.com/a/42490643/1005607
Upvotes: 1
Reputation: 980
Many clients truncate large Request parameter --> limit on query String
Please use @RequestBody
as in
@RequestMapping(value="/loadParticipantsExportValues", method=RequestMethod.POST)
public void loadParticipantsExportValues(@RequestBody String participants) throws Exception{
//....
}
Upvotes: 2