【问题标题】:java.lang.IllegalStateException: More than the maximum number of request parameters (GET plus POST) for a single request ([512]) were detectedjava.lang.IllegalStateException:检测到超过单个请求([512])的请求参数(GET 加 POST)的最大数量
【发布时间】:2026-02-20 09:30:01
【问题描述】:

我有一个带添加按钮,这个按钮像这样向数据表添加一行。

public void addDetail(){
  detail.add(new Detail());
  RequestContext.getCurrentInstance().update(":theDatatable");
}

问题是当数据表有太多行(例如200行)时,因为渲染过程中的ajax调用有很多参数,服务器会抛出这个错误

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

我无法解决这个改变了 maxParameterCount 但请求的时间没有改变(~2000ms)

我的问题是:是否可以使用 widgetVar o 东西通过 javascript 添加单行?还有其他解决方案吗?

谢谢!!

编辑:

这是 xhtml 代码的一部分。

    <p:dataTable id="theDatatable" var="_det" rowIndexVar="indexVar"
    style="width:100%;" widgetVar="dataTableDetalleWidget" 
    rendered="#{neLiquidacionController.currentCab.tipoLine==neLiquidacionController.facturar.value}"
    editMode="row" editable="true" 
    value="#{neLiquidacionController.detail}">
    <p:ajax event="rowEdit" update="@this" />
    <p:column headerText="Item" width="40" style="background:#EEEEEE;">
        <h:outputText value="#{indexVar+1}" />
    </p:column>
    <p:column headerText="Descripción">
        <p:cellEditor>
            <f:facet name="output">
                <p:outputLabel value="#{_det.productos.descripcion}" />
            </f:facet>
            <f:facet name="input">
                <p:autoComplete id="producto" placeholder="ingrese un valor.."
                    disabled="#{neLiquidacionController.currentCab.estado!='PENDIENTE'}"
                    converter="#{productoConverter}" autocomplete="true"
                    required="true" onfocus="this.select();"
                    onkeypress="if(event.keyCode==27){addDetail();}"
                    completeMethod="#{neLiquidacionController.completeProducto}"
                    var="p" itemLabel="#{p.descripcion}" itemValue="#{p}"
                    scrollHeight="300" forceSelection="true" dropdown="true"
                    value="#{_det.productos}">
                    <p:ajax event="itemSelect" async="true"
                        listener="#{neLiquidacionController.elementChangeProducto}"></p:ajax>
                    <f:facet name="itemtip">
                        <p:panelGrid columns="2">
                            <f:facet name="header">Producto</f:facet>
                            <p:column headerText="Codigo">
                                <h:outputLabel value="#{p.codProducto}" />
                            </p:column>
                            <p:column headerText="Descripcion">
                                <h:outputLabel value="#{p.descripcion}" />
                            </p:column>
                        </p:panelGrid>
                    </f:facet>
                </p:autoComplete>
            </f:facet>
        </p:cellEditor>
    </p:column>
</p:dataTable>

<pe:remoteCommand name="addDetail" async="true" partialSubmit="true"
    process="@this" 
    actionListener="#{neLiquidacionController.addDetail()}">
</pe:remoteCommand>

使用 Primefaces 5.0 和 PrimeFaces 扩展 2.0

Firebug 请求和响应。

javax.faces.ViewState   3374159165244990485:-1029187269574844262
javax.faces.behavior.even...    keypress
javax.faces.partial.ajax    true
javax.faces.partial.event   keypress
javax.faces.partial.execu...    notaEnvioDet:detalle:98:salida
javax.faces.source  notaEnvioDet:detalle:98:salida
notaEnvioDet:detalle:0:co...    7840048000043
notaEnvioDet:detalle:0:pr...    4

......
notaEnvioDet:detalle:98:pr...   680
notaEnvioDet:detalle:98:pr...   AZUCAR CONFITERO X 1Kg.
notaEnvioDet:detalle:98:sa...   37.0
notaEnvioDet:nroDocumento   824

这会发送所有数据表值... 以及这里的回应:

<?xml version='1.0' encoding='UTF-8'?>
<partial-response><changes><update id="messages"><![CDATA[<span id="messages"></span><script id="messages_s" type="text/javascript">$(function(){PrimeFaces.cw('Growl','growlWidget',{id:'messages',sticky:false,life:6000,escape:true,msgs:[]});});</script>]]></update><update id="usuarios:j_idt482"><![CDATA[<div id="usuarios:j_idt482" class="ui-messages ui-widget" aria-live="polite"></div>]]></update><update id="javax.faces.ViewState"><![CDATA[3374159165244990485:-1029187269574844262]]></update></changes></partial-response>

【问题讨论】:

  • 问题中的支持 bean 操作方法代码是无关紧要的,因为甚至根本没有达到该方法。您最好显示应该触发此操作方法的视图(XHTML)代码。我的猜测是添加partialSubmit="true" 应该可以做到,如果还没有尝试的话。
  • ajax 调用使用了 primefaces 扩展的 pe:remote 命令,这有 partialSubmit="true",编辑添加 xhtml 代码的问题。谢谢
  • 好的,它的process 属性怎么样?它是只处理相关数据还是整个表单?
  • 发布部分萤火虫日志控制台..这会发送请求中的所有数据..另一种方式来做到这一点?
  • 看起来partialSubmit="true" 被忽略了。如果您改用 PrimeFaces 自己的 &lt;p:remoteCommand&gt; 会怎样?

标签: jsf primefaces datatable jboss7.x


【解决方案1】:

如果你使用服务器作为 Jboss,你可以在standalone.xml 中进行更改,就像

 <system-properties>
    <property name="org.apache.tomcat.util.http.Parameters.MAX_COUNT" value="2000"/>
</system-properties>

【讨论】: