AJAX 中文参数 需要编码后传给服务端,然后在服务端用utf-8解码,因为ajax(post请求)默认是utf-8编码;
如:js
ajax.setParam("topic.content", encodeURIComponent(f["topic.content"].value));
java:
URLDecoder.decode(topic.getContent(), "utf-8")
----------------------------------------------------------------------------------------------------------
utf-8
encodeURIComponent <------------------------->URLDecoder.decode
而get的请求则不一样;get请求不走filter
需要在js端用两次编码:
encodeURIComponent(encodeURIComponent(f["topic.content"].value))。
【http://hi.baidu.com/tianqinhot/blog/item/7db95f598080192c2934f02c.html】