zoukankan      html  css  js  c++  java
  • 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";
            }
  • 相关阅读:
    HDU 1261 字串数(排列组合)
    Codeforces 488C Fight the Monster
    HDU 1237 简单计算器
    POJ 2240 Arbitrage
    POJ 3660 Cow Contest
    POJ 1052 MPI Maelstrom
    POJ 3259 Wormholes
    POJ 3268 Silver Cow Party
    Codesforces 485D Maximum Value
    POJ 2253 Frogger(最短路)
  • 原文地址:https://www.cnblogs.com/zhaoatian/p/11535686.html
Copyright © 2011-2022 走看看