如何获得整个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...
我的意思是,帖子是整体,减去标题???
I mean, is the post the whole body, minus headers???
所以,我如何用java解析这样的帖子?
so, how can I parse such a post message with java?
我必须使用
HttpServletRequest.getInputStream?
HttpServletRequest.getInputStream?
任何有用的例子?
如何拨打电话?我的意思是,在身体中发布价值,而不是在特定参数中... ...
and how do I make such a call? I mean, posting value in the body and not in a specific parameter...
非常感谢
推荐答案
服务器端代码如下所示:
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();
}
其中request是HttpServletRequest。要从客户端进行测试,您可以使用海报与Firefox。
Where request is the HttpServletRequest. For testing this from the client side, you can use Poster with Firefox.
这篇关于如何获得整个http帖子的价值?解析宁静的帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!