java 代码
- public String getPostContent(HttpServletRequest request){
- ServletInputStream is = request.getInputStream();
- ByteArrayOutputStream baos = null;
- baos = new ByteArrayOutputStream();
- int iLength = 1024;
- int bytesRead = 0;
- byte[] buff = new byte[iLength];
- while (true)
- {
- bytesRead = is.read(buff);
- if (bytesRead < 1)
- break;
- baos.write(buff, 0, bytesRead);
- }
- return new String(baos.toByteArray(),"utf-8");
- }
本文介绍了一种使用Java从HttpServletRequest中读取POST请求内容的方法。通过ServletInputStream读取输入流,并将其转换为字符串,便于进一步处理。
1173

被折叠的 条评论
为什么被折叠?



