标签:config temp pos oms prim ted bytes response 编码
首先,不要用get传中文,我试了一些方法发现不行,所以果断决定用post传参,
这里用 encodeURI 进行一次编码传入后端
注意:${tplname} 要加 ‘
$.ajax({ url: ‘/RM/controller/json/ConfigTemplateCustomController/fetchTemplateCustomContentsByTplName/tplname/post‘, type: ‘POST‘, async: false, data:{ ‘tplname‘:encodeURI(‘${tplname}‘) }, success:
这样解码后再 getBytes 就解决了
@RequestMapping(value = "controller/json/ConfigTemplateCustomController/fetchTemplateCustomContentsByTplName/tplname/post", method = RequestMethod.POST) @ResponseBody public BaseResult fetchTemplateCustomContentsByTplName(String tplname) throws UnsupportedEncodingException { tplname = URLDecoder.decode(tplname,"utf-8"); tplname = new String(tplname.getBytes("ISO-8859-1"),"UTF-8"); return ResultUtil.success().add("TemplateCustom", configTemplateCustomService.selectByPrimaryKey(tplname)); }
javaweb 解决jsp中${}传递中文值到后端以及get请求中文乱码的问题
标签:config temp pos oms prim ted bytes response 编码
原文地址:https://www.cnblogs.com/kinome/p/9983735.html