设置
String source = URLEncoder.encode("中文", "utf-8");
String result = URLDecoder.decode(source, "utf-8");
ServerHttpRequest mutableReq = null;
try {
mutableReq = exchange.getRequest().mutate()
.header(CacheConstant.DETAILS_USER_ID, userId)
.header(CacheConstant.DETAILS_USERNAME, URLEncoder.encode("姓名", "utf-8"))
.header(CacheConstant.DETAILS_LOGINNAME, loginName)
.header(CacheConstant.DETAILS_DEPTID, deptId)
.header(CacheConstant.DETAILS_AREA_CODE, URLEncoder.encode("安徽", "utf-8"))
.header(CacheConstant.DETAILS_USER_TYPE,URLEncoder.encode("租户", "utf-8"))
.build();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
获取
URLDecoder.decode(ServletUtils.getRequest().getHeader(CacheConstant.DETAILS_USERNAME), "utf-8");