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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。