`

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");

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics