blogzhoubo 发表于 2013-1-29 08:37:25

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");
 
 
页: [1]
查看完整版本: prototype ajax传递参数乱码解决方法