当前位置: 代码迷 >> Ajax >> prototype ajax传递参数乱码解决办法
  详细解决方案

prototype ajax传递参数乱码解决办法

热度:709   发布时间:2012-11-22 00:16:41.0
prototype ajax传递参数乱码解决方法

1.JSP文件

function ajaxReq(){
var url = "ChatRoomServlet";
var param = "fname=${param.fname}&tname=${param.tname}";
new Ajax.Request(url,{
?method:"get",
?parameters:encodeURI(param),
?requestHeaders:['Cache-Control','no-cache','If-Modified-Since','0'],
??? onSuccess:function(httpObj){
??? ?$("chatarea").value = httpObj.responseText;
??? },
??? onFailure:function(httpObj){
??? }
});

?

2.servlet的doGet方法:

?

String fname = request.getParameter("fname");
fname = new String(fname.getBytes("ISO-8859-1"),"UTF-8");

?

?

  相关解决方案