I've got a form in my view which send objects to my controller, but the matter is that I've got an exception if I send more than 256 objects :
org.springframework.beans.InvalidPropertyException: Invalid property 'followers[256]' of bean class [org.myec3.portalgen.plugins.newsletter.dto.FollowerFileDto]: Index of out of bounds in property path 'followers[256]'; nested exception is java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
So I was wondering why such a limit, and I found this topic : https://stackoverflow.com/a/24699008/4173394
But it doesnt seem to work for me (probably a bad use from me).
Here is my structure : My view is called createUpdate.vm and post my form like this :
<form id="createFollowerFileForm" method="post" action="#route("followerFileController.upsertFollowerFile")" enctype="multipart/form-data" class="form_styled">
My function upsertFollowerFile in FollowerFileController :
@InitBinder
public void initBinder(WebDataBinder dataBinder) {
// this will allow 500 size of array.
dataBinder.setAutoGrowCollectionLimit(500);
}
@Secured({ "ROLE_SUPER_ADMIN_PORTALGEN", "ROLE_CUSTOMER_PORTALGEN", "ROLE_ADMIN_PORTALGEN", "ROLE_WRITER_PORTALGEN" })
public String upsertFollowerFile(
@ModelAttribute(value = "followerFile") FollowerFileDto followerFileDto,
BindingResult result, ModelMap model, HttpServletRequest request) {
And my class FollowerFileDto :
public class FollowerFileDto {
private String title;
private Long followerId;
private boolean isDeletable;
private List<FollowerDto> followers;
public FollowerFileDto() {
this.followers = new ArrayList<FollowerDto>();
}
As you can see in my controller, I tried to set more than 256 allowed objects (500) with the @InitBinder annotation, but it doesnt work at all. The InitBinder function is never called. Did I do anything wrong ? Thanks for you answers ;)