Servlet容器中的请求参数顺序 [英] Request Parameter order in Servlet Containers

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

问题描述

显然,请求参数的顺序未保留在Tomcat Servlet容器中(对于Google,似乎其他容器也存在相同的问题).

Apparently the order of request parameters is not preserved in the Tomcat servlet container (per google it seems other containers share the same problem).

这似乎是非常错误的.

如何从HttpServletRequest恢复请求参数的实际顺序?

How would one restore the actual order of request parameters from a HttpServletRequest?

编辑对于那些认为请求参数顺序无关紧要的人而言,BTW之间是有区别的:

EDIT BTW for those that think order for request parameters does not matter there is a difference between:

http://blah?a=1&a=2

http://blah?a=2&a=1

因此顺序对于重复的请求参数确实很重要(幸运的是Java确实处理了此权利).

So order does matter for duplicate request parameters (luckily Java does handle this right).

推荐答案

通常,您不应该依赖于参数的顺序.如果您确实确定这是必要的,则可以:

Normally you should not depend on the order of parameters. If you are really sure this is necessary, you can:

  • 使用 request.getQueryString()查看 GET 参数
  • 获取原始请求( request.getInputStream())并读取提交的 POST 参数.
  • use request.getQueryString() to see GET parameters
  • get the raw request (request.getInputStream()) and read the submitted POST params.

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

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