'Truncated post body / @ModelAttribute in spring boot
I have a problem with a spring boot application. Using spring boot 2.0.0 with thymeleaf.
Long story short, i have quite a huge form with a lot of data (not quite 1 MB), that is consumed on the controller side, via @ModelAttribute ReviewModel viewModel. However the arriving ReviewModel only contains a subset of the data sent.
If i consume the same request i.e. in a PHP script i can see that the request contains all the data expected. So my best guess is that the request body somehow gets truncated. However i did not found anything related in the configuration options and also a websearch. I have configured a huge multipart limit as i am also dealing with larger uploaded files, but i think that does not affect a normal POST request.
The form itself is just defined in the template as
<form id="mainForm" action="#" th:action="@{...}" th:object="${review}" method="post">
The ViewModel
public class ReviewModel {
private List<ContractReviewModel> models = new ArrayList<>();
// ... with getter and setter
}
I also tried
server.tomcat.max-http-post-size=100000000
server.tomcat.max-swallow-size=100000000
EDIT:
I did some more digging and firstly tried to add enctype="multipart/form-data" to my form. Which resulted in a java.lang.IllegalStateException: More than the maximum number of request parameters... error. This lead me to Max number of request parameters reached in spring boot application.
Although i incorporated this solution i get a java.lang.IndexOutOfBoundsException somewhere in org.springframework.validation.DataBinder -> org.springframework.beans.AbstractNestablePropertyAccessor. Spring framework seemingly cannot handle this large dataset, which really baffles me, as i would say this a very basic usecase. As this solution follows the docs i cannot imagine i have overwritten some other value that is necessary as docs would have mentioned that. It does not make any difference if i use multipart/form-data or not.
This problem somehow seems deeply rooted. To me the question remains why spring boot seemingly cannot handle large data set and why this only applies when setting a custom limit on paramater count.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
