SpringMVC前台提交参数绑定list时大小超过256 java.lang.IndexOutOfBoundsException解决办法
2016-11-30 18:25
621 查看
springMVC框架提交参数list时,springmvc默认只能接收到255个数据,当你前台传的数据长度大于255位的时候就会报错
例如我在前台传输的solutionModelList的长度有364位,在chrome控制台可以看到
![](https://img-blog.csdn.net/20161130180344770)
然后在后台接收
报错
![](https://img-blog.csdn.net/20161130180957585)
解决办法:在你的controller层加上初始化方法
但是这个方法之针对这样处理过的类有用,要想在整个项目下都定义长度,如下:
例如我在前台传输的solutionModelList的长度有364位,在chrome控制台可以看到
然后在后台接收
@RequestMapping("/saveFinance.json") @ResponseBody public AjaxObj saveFinance(List<SolutionModelEntity> solutionModelList) { }
报错
解决办法:在你的controller层加上初始化方法
//这个类初始化的时候会首先调用init方法 @InitBinder //类初始化是调用的方法注解 public void initBinder(WebDataBinder binder) { //给这个controller配置接收list的长度100000,仅在这个controller有效 binder.setAutoGrowCollectionLimit(100000); }
但是这个方法之针对这样处理过的类有用,要想在整个项目下都定义长度,如下:
定义一个初始化类 public class myInitializer implements WebBindingInitializer { @Override public void initBinder(WebDataBinder binder) { binder.setAutoGrowCollectionLimit(100000); } } 然后在配置文件配置 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> <property name="webBindingInitializer"> <bean class="xxx.myInitializer"/> //class指myInitializer类 </property> </bean>
相关文章推荐
- Sping 接收前台传过来的数组大小超过256 报 java.lang.IndexOutOfBoundsException: Index: 256, Size: 256 的错误解决
- Nutch 遇见hits.getHits()出现java.lang.ArrayIndexOutOfBoundsException解决办法
- SpringMVC提交参数绑定list时,默认配置如果list大小超过256,就会报错
- SpringMVC提交参数绑定list时,默认配置如果list大小超过256,就会报错
- [经验小结]jxl写excel时产生“java.lang.ArrayIndexOutOfBoundsException: 5”问题的解决办法
- MyEclipse 2016 在部署启动新项目时报 Could not publish to the server. java.lang.IndexOutOfBoundsException 解决办法
- jersey java.lang.IndexOutOfBoundsException的解决办法
- java.lang.IndexOutOfBoundsException 错误解决
- 解决java.lang.IllegalArgumentException: pointerIndex out of range 或者 arrayindexoutofboundsexception的错误
- java.lang.ArrayIndexOutOfBoundsException异常分析及解决
- Tomcat 或JBOSS java.lang.ArrayIndexOutOfBoundsException: 8192原因及其解决方法
- 点击listview item 报 java.lang.IndexOutOfBoundsException 问题解决方案分析
- 【Spring】java.lang.IndexOutOfBoundsException: Index: 256, Size: 256
- java.lang.ArrayIndexOutOfBoundsException异常分析及解决
- 解决java.lang.ArrayIndexOutOfBoundsException问题(android:singleLine="true")
- java.lang.IndexOutOfBoundsException: Index: 5, Size: 5解决
- eclipse Java文件打开异常解决方法 :java.lang.StringIndexOutOfBoundsException: String index out of range: 26
- Hibernate query.list()查询发生java.lang.StringIndexOutOfBoundsException: String index out of range: 0错误
- java.lang.ArrayIndexOutOfBoundsException 异常分析及解决
- mvn install:java.lang.StringIndexOutOfBoundsException: String index out of range: -1问题的解决