How to retreive raw post data from HttpServletRequest in java
2015-07-08 09:57
721 查看
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();
}
相关文章推荐
- How to retreive raw post data from HttpServletRequest in java
- STM32W108无线传感器网络嵌入式uCOS-II的移植及实时环境监测
- Facebook网络模拟测试工具ATC使用
- 【计算机网络】期末复习
- TCP协议和UDP协议简单实例
- HTTP深入浅出 http请求
- 全国人大:网络安全法(草案)全文
- 更具笔格:网络文案权威指南
- 网络编程
- 32 GroupSock(AddressPortLookupTable)——live555源码阅读(四)网络
- 31 GroupSock(AddressString)——live555源码阅读(四)网络
- 30 GroupSock(Port)——live555源码阅读(四)网络
- 简单几招模拟网络超时情况
- 深度卷积神经网络的行人检测 (pedestrian detection)
- sql server连接字符串与tcp/ip开启
- 利用block封装网络请求类
- TCP/IP详解学习笔记——IP协议
- 五轴加工的RTCP技术
- CentOS系统时间与网络同步
- 黑马程序员——JAVA笔记——网络