从HttpServletRequest中获取body中的参数

Map<String,Object> params = new HashMap<String, Object>();
        BufferedReader br;
        try {
            br = request.getReader();
            String str, wholeStr = "";
            while((str = br.readLine()) != null){
                wholeStr += str;
            }
            if(StringUtils.isNotEmpty(wholeStr)){
                params = JSON.parseObject(wholeStr,Map.class);
            }
        } catch (IOException e1) {
            logger.error(""+e1);
        }

 

posted @ 2020-07-24 16:20  以你为名的世界  阅读(14329)  评论(0编辑  收藏  举报