How to retreive raw post data from HttpServletRequest in java

转载 2015年07月08日 09:57:19

public static String getPostData(HttpServletRequest req) {
    StringBuilder sb = new StringBuilder();
    try {
        BufferedReader reader = req.getReader();
        reader.mark(10000);

        String line;
        do {
            line = reader.readLine();
            sb.append(line).append("\n");
        } while (line != null);
        reader.reset();
        // do NOT close the reader here, or you won't be able to get the post data twice
    } catch(IOException e) {
        logger.warn("getPostData couldn't.. get the post data", e);  // This has happened if the request's reader is closed    
    }

    return sb.toString();
}

相关文章推荐

java中的post请求之raw请求--微信api调用java代码示例

使用chrome浏览器的postman插件,post请求时有一个选项是f

PHP用HTTP_RAW_POST_DATA来接收post过来的数据

PHP用HTTP_RAW_POST_DATA来接收post过来的数据 发表回复 用$GLOBALS[‘HTTP_RAW_POST_DATA’]这个变量就可以接收post raw dat...

java基于HTTP协议post传参,获取参数

ja

[原]java中的post请求之raw请求--微信api调用java代码示例

调试微信推广支持中二维码生成api的接口,使用chrome浏览器的postman插件,post请求时有一个选项是form-data,或者raw,使用raw可以请求成功,from-data不知道怎么组装...

How to send raw packet data from Opendaylight controller to network datapath

In this post, two methods are giving to demonstrate how to deliver raw packet-data to network from O...

How to Post Data and Fetch Remote Pages from PHP Scripts

http://phpstarter.net/2008/12/how-to-post-data-and-fetch-remote-pages-from-php-scripts/ Published: ...

How to send HTTP request GET/POST in Java

In this article, we will show you two examples to make HTTP GET/POST request via following APIs S...

How-to read data from selected tree node

By default, the SelectionListenerproperty of an ADF bound tree points to the makeCurrent method of ...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)