js向Action请求时出现中文乱码如何解决?
在js中代码如下:
function openDetails(){
var AgeName = encodeURIComponent(tFs.name);//用encodeURIComponent(xx)处理中文
var AgeAdress = encodeURIComponent(tFs.address);
var AgeTel = encodeURIComponent(tFs.tel);
var Fid = encodeURIComponent(tFs.fwzxid);
//alert(AgeName+"/"+AgeAdress+"/"+AgeTel+"/"+"fid=="+Fid);
var url = "../d_map/ListAction.do?Fname=BasicInformation&AgeName="+AgeName+"&AgeAdress="+AgeAdress+"&AgeTel="+AgeTel+"&Fid="+Fid+"&Index=1";
if(!win){
win = new Ext.Window({
contentEl : 'openiframe',
width : 750,
height : 460,
closeAction :'hide',
autoScroll : false,
collapsible :true,
collapsible :false,
title :"查看详细信息"
});
}
win.show();
Ext.get('oiframe').dom.src = url;
}
在java中代码处理如下:
String AgeName = new String(request.getParameter("AgeName").getBytes("ISO-8859-1"),"UTF- 8");
String AgeAdress = new String(request.getParameter("AgeAdress").getBytes("ISO-8859-1"),"UTF-8");
String AgeTel = new String(request.getParameter("AgeTel").getBytes("ISO-8859-1"),"UTF-8");
String Fid = request.getParameter("Fid");//Fid是英文的不用处理。