有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Resltet不会从post请求返回url参数

我有一个请求:

https://localhost/rest/myAPI/1.0/myStatusUpdate?usr=me&pwd=secret

我的请求标题:

User-Agent: Fiddler
Content-type: application/x-www-form-urlencoded
Host: localhost
Content-Length: 67

我使用resltet1.1。(该版本的resltet已经在该项目中使用了好几年,尚未更改)

之前,这行代码返回了url中的查询参数:

requestBodyParams = request.getEntityAsForm()
urlParams = request.getResourceRef().getQueryAsForm()

requestBodyParams。如果URL参数为,则size()=0。大小()>;0

也就是说,如果我有一些参数传入URL,我就无法从RequestBody获取任何参数

即使请求正文中有一些参数,request.getEntityAsForm()如果url中有一些参数,也会返回空值

我想知道为什么?在它起作用之前

它可能与Tomcat有关(以前是Tomcat6,现在我使用Tomcat7


换句话说:现在我必须遵循这个规则:

  1. put everything to url params and not to use request body (request body will be empty)
  2. put everything to request body and not to use url params

共 (0) 个答案