首页 > 代码库 > js传后台action中文乱码处理
js传后台action中文乱码处理
public ActionForward confirmTrans(final ActionMapping mapping, final ActionForm actionForm, final HttpServletRequest req, final HttpServletResponse res) throws Exception { String str= decodeToUtf(req.getParameter("str")); return null; } public static String decodeToUtf(Object obj) { String reStr = obj != null ? obj.toString() : ""; String regEx = "[+]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(reStr); reStr = m.replaceAll("【SPSOFT】+【SPSOFT】"); try { reStr = URLDecoder.decode(reStr, "UTF-8"); reStr = reStr.replaceAll("【SPSOFT】+【SPSOFT】", "+"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return reStr; }
var str= encodeURI(str); str= encodeURI(str); var url = path + actionPath + "&str=" + str;
本文出自 “学习,总归要学” 博客,请务必保留此出处http://phzg03.blog.51cto.com/5570214/1572148
js传后台action中文乱码处理
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。