ITeye博客

读取request中post过来的内容

superallen · 2007-09-20 10:56 · Markdown

java 代码

  1. public String getPostContent(HttpServletRequest request){
  2. ServletInputStream is = request.getInputStream();
  3. ByteArrayOutputStream baos = null;
  4. baos = new ByteArrayOutputStream();
  5. int iLength = 1024;
  6. int bytesRead = 0;
  7. byte[] buff = new byte[iLength];
  8. while (true)
  9. {
  10. bytesRead = is.read(buff);
  11. if (bytesRead < 1)
  12. break;
  13. baos.write(buff, 0, bytesRead);
  14. }
  15. return new String(baos.toByteArray(),"utf-8");
  16. }

评论(3)

  1. #3 楼 · badboy4471 · 2008-11-28 15:49

    3ks,标记一下。

  2. #2 楼 · applerao · 2008-09-04 16:41

    simple but useful! :D

  3. #1 楼 · applerao · 2008-09-04 16:40

    good artical

评论功能维护中,当前仅展示历史评论。