首页新闻找找看学习计划

java http request body

0
悬赏园豆:5 [已解决问题] 解决于 2015-07-31 11:26

如何在后台拿到request中的body?

王翊的主页 王翊 | 初学一级 | 园豆:3
提问于:2015-07-29 15:41
< >
分享
最佳答案
0

    BufferedReader reader = null;
        StringBuilder sb = new StringBuilder();
        try
        {
            reader = new BufferedReader(new InputStreamReader(request
                    .getInputStream(), "utf-8"));
            String line = null;

            while ((line = reader.readLine()) != null)
            {
                sb.append(line);
            }
        } catch (IOException e)
        {
            e.printStackTrace();
        } finally
        {
            try
            {
                if (null != reader)
                {
                    reader.close();
                }
            } catch (IOException e)
            {

            }
        }
        return sb.toString();

收获园豆:5
烽火情怀 | 菜鸟二级 |园豆:373 | 2015-07-30 09:53
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册