春天花会开

***********

统计

留言簿(4)

阅读排行榜

评论排行榜

Servlet获取Ajax POST数据乱码的一种解法

1. 对中文参数编码encodeURI(chinesePara);
  poststr = "username="+encodeURI("中文");

2.服务器端获取参数后解码

String username = new String(request.getParameter("username").getBytes("ISO-8859-1"),"UTF8");  

  -----------------------------------------------------------

  http_request.open("POST", url, true);
  http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  http_request.send(poststr);

---------------------------------------------------------------



posted on 2006-07-07 21:17 春天花会开 阅读(2640) 评论(1)  编辑  收藏

评论

# re: Servlet获取Ajax POST数据乱码的一种解法 2006-08-09 16:33 小贱

请能解释一下吗?
困扰中  回复  更多评论   


只有注册用户登录后才能发表评论。


网站导航: