【问题标题】:Getting a parameter from ServletRequest throws illegalStateException从 ServletRequest 获取参数会抛出非法状态异常
【发布时间】:2019-08-12 09:49:23
【问题描述】:

我在每个请求都调用的过滤器之一中有此代码。

httpRequest.getParameter(tabId);

过滤后我的请求不断失败。在调试时,我发现这段代码第一次抛出这个异常,现在说如果我使用“inspect”执行这个代码,它会抛出这个异常,如果我再次使用“inspect”或“forward debug”执行它,它会给出“null”并完成流程。我不明白为什么它在第一次执行此代码时会这样工作,因为请求中没有“tabId”。

18:44:03,443 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[default-host].[/workbench].[action]] (http-0.0.0.0:8090-5) JBWEB000236: Servlet.service() for servlet action threw exception: java.lang.IllegalStateException: JBWEB002004: More than the maximum number of request parameters (GET plus POST) for a single request (128) were detected. Any parameters beyond this limit have been ignored. To change this limit, set the maxParameterCount attribute on the Connector.
    at org.apache.tomcat.util.http.Parameters.addParameter(Parameters.java:184) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
    at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:356) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
    at org.apache.tomcat.util.http.Parameters.processParameters(Parameters.java:213) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
    at org.apache.catalina.connector.Request.parseParameters(Request.java:2885) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
    at org.apache.catalina.connector.Request.getParameter(Request.java:1303) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
    at org.apache.catalina.connector.RequestFacade.getParameter(RequestFacade.java:350) [jbossweb-7.5.28.Final-redhat-1.jar:7.5.28.Final-redhat-1]
    **at com.xyz.IdentityFilter.doFilter(IdentityFilter.java:58) [projectX.jar:]**

【问题讨论】:

    标签: servlets jboss httprequest httpresponse servlet-filters


    【解决方案1】:

    请求正文已经被消费,如果您需要对其进行业务逻辑,则必须将其包装在您的过滤器中(在doFilter(...) 调用之前)。示例见here

    【讨论】:

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