httpclient请求中文乱码问题

我们都知道,一般情况下使用post请求是不会出现中文乱码的。可是在使用httpclient发送post请求报文含中文的时候在发送端数据正常但是到了服务器端就中文乱码了。

编码URLEncoder.encode(depmsOrg,"utf-8");

解码URLDecoder.decode(depmsOrg, "utf-8");

 

@RequestMapping("/adjustProgressListView")
        public String adjustProgressListView(HttpServletRequest request){
            TotAdjustProgress beanAdjust = new TotAdjustProgress();
            try {
                HashMap<String, String> paramMap = new HashMap<String, String>();
                //权限控制
                String depmsOrg = (String) request.getSession().getAttribute("depmsOrg");
                if(depmsOrg!=null&& !depmsOrg.equals("")){
                    paramMap.put("districtBy", URLEncoder.encode(depmsOrg,"utf-8"));
                }
                String jsonResult = HttpClientUtil.sendPost(chainplanmanger_url+"/getServiceStationAdjustProgress.do", paramMap);
                if(StringUtil.isNotEmptyAndNotNull(jsonResult)){
                    beanAdjust = JSON.parseObject(jsonResult, TotAdjustProgress.class);
                }
                request.setAttribute("beanAdjust", beanAdjust);
            } catch (Exception e) {
                logger.error("AdjustProgressListController::adjustProgressListController::", e);
            }
            return "adjust/adjustProgressListView.ftl";
        }

 

posted @ 2019-09-17 17:36  塔下补刀就是菜丶  阅读(769)  评论(0编辑  收藏  举报