Servet 请求丢失了参数

编程入门 行业动态 更新时间:2024-10-28 00:14:33
本文介绍了Servet 请求丢失了参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

关于请求参数在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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-30 03:55:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1389393.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:参数   丢失了   Servet

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!