|
|
一种方式
/*
* 在前台要先双编,在后台取在解
* js代码
* var str = "中文";
* str = encodeURI(str); 1编
* str = encodeURI(str); 2编
* java代码
* String content = request.getParameter("str");
* content = java.net.URLDecoder.decode(content, "UTF-8"); 解码
*/
二种方式
String content = new String(request.getParameter("loginid").getBytes("ISO-8859-1"), "UTF-8");直接写;
三种方式ajax提交
js:
encodeURIComponent(encodeURIComponent(value));
java:
URLDecoder.decode(value,"UTF-8");
其它的就要看乱码情况来解决eg:过滤器;
<span style=""><div style="margin-top: 0px; margin-right: auto; margin-bottom: 0px; margin-left: auto; padding: 0px;">javascript中存在几种对URL字符串进行编码的方法:escape(),encodeURI(),以及encodeURIComponent()。这几种编码所起的作用各不相同。 |
|