Posted on 2007-07-16 15:33
semovy 阅读(2756)
评论(2) 编辑 收藏 所属分类:
J2EE综合
我的统一编码是UTF-8
ajax 的XMLHttpRequest的头部http_request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");默认编码是utf-8,我以post的方式向服务器提交文章
var url = "../../article.do?action=save";
articleXMLHttpRequest = getXMLHttpRequest();
send_request(articleXMLHttpRequest,"post",url,"itemId=" + itemId + "&title=" + title + "&content=" + escape(encodeURIComponent(content)),"xml",initialArticlesList);
经过encodeURIComponent();编码
在服务器解码,用java.net.URLDecoder
String content = new URLDecoder().decode(request.getParameter("content"),"utf-8");以utf-8以方式解码