Servet 请求丢失了参数 [英] Servet request lost the params

查看:34
本文介绍了Servet 请求丢失了参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于请求参数在Tomcat中被丢弃的问题

好吧...显然,即使是在某些服务器上如下最简单的请求也会丢失参数,而有些则可以.

@GET@Path("/get-retrieve")公共字符串 foo(){return ""+httpServletRequest.getParameterMap().size();}

所以返回的值为 0(零).

更新:AccessLogValve 记录的请求包含参数

127.0.0.1 - - [26/Nov/2012:03:04:58 -0800] "POST/api/get-retrieve?x=y HTTP/1.1" 200 16

所以,问题可能出在 Tomcat 的某个地方,因为它丢弃了这些参数...

解决方案

我遇到过一次,经过长时间的调查发现问题出在 Tomcat 的 server.xml 中连接器的定义:

<Connector connectionTimeout="20000" maxHttpHeaderSize="9000" maxParameterCount="100" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

看看maxParameterCount"的定义,在我们的例子中它被设置为 0,这导致所有请求参数都被删除.

Question related to Request parameters are dropped in Tomcat

Well... apparently, even simplest request as below on some servers lost the parameters and some it is OK.

@GET
@Path("/get-retrieve")
public String foo(){
    return ""+httpServletRequest.getParameterMap().size();
}

so returned value is 0 (zero).

Update: the logged request by AccessLogValve contains the parameter

127.0.0.1 - - [26/Nov/2012:03:04:58 -0800] "POST /api/get-retrieve?x=y HTTP/1.1" 200 16

So, probably the problem is somewhere in the Tomcat throwing out those params...

解决方案

I had this once, after a long investigation it turned out the problem was in the definition of the Connector in Tomcat's server.xml :

<Connector connectionTimeout="20000" maxHttpHeaderSize="9000" maxParameterCount="100" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

Look at the definition of "maxParameterCount", in our case it was set to 0 which caused all request parameters to be dropped.

这篇关于Servet 请求丢失了参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆