SpringMVC提交参数绑定list时,默认配置如果list大小超过256,就会报错
使用SpringMVC提交数组时,如果list/array 大小超过256,就会报错。
原因是DataBinder 中默认限制了list最大只能增长到256。
private int autoGrowCollectionLimit = DEFAULT_AUTO_GROW_COLLECTION_LIMIT;
解决方案:
1)在BaseController添加InitBinder方法,其余继承BaseController
@InitBinder public void initBinder(WebDataBinder binder) { binder.setAutoGrowCollectionLimit(Integer.MAX_VALUE); }
2)增加一个WebBindingInitializer类,并在xml中配置。
public class DataBindingInitializer implements WebBindingInitializer { @Override public void initBinder(WebDataBinder binde) { binder.setAutoGrowCollectionLimit(Integer.MAX_VALUE); } }
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="webBindingInitializer"> <bean class="xxx.DataBindingInitializer"/> </property> </bean>
相关推荐
xiaoseyihe 2020-11-16
xiaoseyihe 2020-11-16
世事一场大梦 2020-10-18
jling 2020-10-14
chenyuping 2020-10-06
kyelu 2020-08-03
KAIrving 2020-08-02
xiesheng 2020-08-02
liushall 2020-07-18
shenwenjie 2020-07-07
yunfenglee 2020-07-08
83520298 2020-07-06
Jonderwu 2020-07-05
xiaobater 2020-07-04
范范 2020-06-28
newusb 2020-06-28