【问题标题】:Spring MVC + jquery data binding null for large request大请求的 Spring MVC + jquery 数据绑定 null
【发布时间】:2015-03-28 15:30:09
【问题描述】:

我有一个在前端使用 Spring MVC 和 Jquery 的 Web 应用程序。从 jsp 到控制器的数据绑定适用于小数据。我的表单绑定到一个包含对象列表的对象。

当它试图处理大约 3000 条记录时出现问题,在 myList 上仅找到 2000 条记录。对于 10000 条记录,myList 包含 null

Public class DataBindingObject{
private List<MyObject> myList
}

     /**
     *This is my controller
     */
    @RequestMapping(value="/submit", method=RequestMethod.POST)
    public ModelAndView submitRequest(@ModelAttribute("submitAllocations") DataBindingObject dto) throws ServiceException {
        ModelAndView mav = new ModelAndView("redirect:/search");
    }

如果我达到最大大小,我检查了 tomcat 日志,但没有。 我错过了什么?提前致谢!

编辑

我使用 Firebug 检查了整个请求负载是否正在发送到控制器,显然它确实如此。由于某种原因,控制器无法绑定整个请求负载。奇怪的是,对于相当大的数据,它似乎上限为 2000,而对于大数据,它的上限为 null。我们的应用程序使用WebDataBinder 将请求绑定到我们的对象中,似乎问题就出在这里。

/**
     * Sets the initial list size for arrays used in ModelAttributes.
     * 
     * @param dataBinder
     */
    @InitBinder
    private void initBinder(WebDataBinder dataBinder) {
        dataBinder.setAutoGrowCollectionLimit(listSizeLimit);
    }

【问题讨论】:

    标签: java jquery spring-mvc


    【解决方案1】:

    我们终于找到了罪魁祸首! Tomcat 有一个 maxPostSizemaxPostSize maxParameterCount 设置限制了我们的请求!不过奇怪的是,它并没有像我从其他人那里读到的那样抛出java.lang.IllegalStateException,这使得调试变得如此困难。

    我刚刚在位于my/tomcat/directory/confserver.xml 中添加了这些设置,并将其设置为-10 以禁用限制。

    不过,我不在乎它为什么不抛出异常。但我很高兴我们找到了解决方案。

     <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
                       maxThreads="150" scheme="https" secure="true"
                       clientAuth="false" sslProtocol="TLS" 
                   keystoreFile="/bin/muKeystore.jks"
                   keystorePass="myPassword" maxPostSize="0" maxParameterCount="-1" maxHeaderCount="-1" />
    

    参考: http://sisis.bth.rwth-aachen.de:8080/docs/config/ajp.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多