简体   繁体   English

如何获得 http 帖子的整体价值? 解析宁静的帖子

[英]how to get a the value of an http post as a whole? parsing restful post

Is it my ideea or in rest-web services a post comes "with no name", so say something...是我的想法还是在 rest-web 服务中,一个帖子“没有名字”,所以说点什么......

I mean, is the post the whole body, minus headers???我的意思是,帖子是整个正文,减去标题???

so, how can I parse such a post message with java?那么,如何使用 java 解析这样的帖子消息?

do I have to use我必须使用吗

HttpServletRequest.getInputStream? HttpServletRequest.getInputStream?

http://www.softlab.ntua.gr/facilities/documentation/unix/java/servlet2.2/javax/servlet/http/HttpServletResponse.html http://www.softlab.ntua.gr/facilities/documentation/unix/java/servlet2.2/javax/servlet/http/HttpServletResponse.html

any useful example?任何有用的例子?

and how do I make such a call?我该如何拨打这样的电话? I mean, posting value in the body and not in a specific parameter...我的意思是,在正文中而不是在特定参数中发布值...

thanks a lot多谢

Fiddler is really useful for this sort of thing. Fiddler对这类事情非常有用。 It is acts as a standard http proxy on your local machine.它充当本地计算机上的标准 http 代理。 You can view the post body and headers etc in it's interface.您可以在其界面中查看帖子正文和标题等。 You just have to tell your code to use an HTTP proxy (usually just 1 or 2 lines of )你只需要告诉你的代码使用 HTTP 代理(通常只有 1 或 2 行)

The server side code would look like the following:服务器端代码如下所示:

StringBuilder input = new StringBuilder();
BufferedReader reader = request.getReader();
String line = reader.readLine();
while (line != null) {
    input.append(line);
    line = reader.readLine();
}

Where request is the HttpServletRequest.其中请求是 HttpServletRequest。 For testing this from the client side, you can use Poster with Firefox.要从客户端对此进行测试,您可以将Poster与 Firefox 一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM