스프링 동적리스트 바인딩의 경우 최대 256개까지가 기본설정으로 되어 있다.

만약, 256개 이상을 파라미터로 넘기게 된다면 IndexOutOfBoundsException이 발생하게 될 것이다.


해결방법은 스프링 InitBinder의 기본설정 값을 변경해준다.

(LazyList를 이용하여 256개를 확장하는 방법도 있는 것 같은데, 이 방법은 안써봐서 패스~)


@Controller
public class TestController {
	private static final int AUTO_GROW_COLLECTION_LIMIT = 500;

	@InitBinder
	public void initBinder(WebDataBinder dataBinder) {
		dataBinder.setAutoGrowCollectionLimit(AUTO_GROW_COLLECTION_LIMIT);
	}
}


그리고 톰캣쪽 maxParameterCount값도 한번 확인해 보는 것이 좋다.

필자는 최대 500개의 리스트를 바인딩하기 위해 위와 같은 설정을 하였는데, 변경하고도 계속 다음과 같은 오류가 발생했다.


경고: More than the maximum number of request parameters (GET plus POST) for a single request ([10,000]) were detected. Any parameters beyond this limit have been ignored. To change this limit, set the maxParameterCount attribute on the Connector.


톰캣은 maxParameterCount값이 기본으로 10000개가 설정되어 있는데, 이 이상이 초과가 되면  에러가 발생함.

그래서 아래와 같이 -1 무제한으로 변경.

정확한 최대 파라미터 갯수가 측정될 경우엔 숫자를 써주는 것이 더 좋을듯하다.


<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443"
               URIEncoding="UTF-8"
               maxParameterCount="-1"/>



Posted by SungHoon, Park
,