HttpServletRequest获取头部中文参数乱码 问题:通过请求头传递中文参数,获取时乱码原因:请求头不能传递中文参数解决办法,通过将参数编解码的方式解决传递中文参数乱码问题放入时进行编码:使用时解码:其他情况传递请求头传递中文,也要编解码。如前后台交互设置请求头 问题:通过请求头传递中文参数,获取时乱码 原因:请求头不能传递中文参数 解决办法,通过将参数编解码的方式解决传递中文参数乱码问题 放入时进行编码: String username="用户名"; try { username= URLEncoder.encode(user.getUsername(),"UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } httpHeader.set("username-header",username); 使用时解码: String username = request.getHeader("username-header"); try { username = URLDecoder.decode(username, "UTF-8"); } catch (Exception e) { e.printStackTrace(); } return username; 其他情况传递请求头传递中文,也要编解码。如前后台交互设置请求头