AppEngine:如何查看 POST 请求中的内容

g12*_*23k 1 java post google-app-engine servlets request

我向 AppEngine 服务器发送 POST 请求。HttpServletRequest 说我:

POST /connexionDeconnexion HTTP/1.1
User-Agent: Java/1.6.0_20
Host: localhost:8888
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 25
Run Code Online (Sandbox Code Playgroud)

我已经发送了世界“HelloHelloHelloHelloHello”,根据Content-Length是正确的。但是,我不知道如何恢复它。你能解释一下吗?

Ale*_*exR 5

正如 Jigar 所说,您可以使用request.getParameter(). 如果您真的提交表单或将参数指定为 URL 参数 (http://myhost/mypath?myparam=myvalue),这将起作用。

如果您将数据作为 POST 正文发送,您应该从它的正文中读取它,即通过调用检索输入流request.getInputStream(),然后从该流中读取。