关于tomcat切换到websphere遇到的中文乱码问题

kerisyml 2011-06-17 10:19:21
JSP页面中的javaspcript
function openMapBSD(slac,sid,sjd,swd,dz){
alert(dz);
testC = new Array();
var url="./MapManager>LocationBaseStation.do";
var data="&trackType="+obj+"&slac="+slac+"&sid="+sid+"&sjd="+sjd+"&swd="+swd+"&dz="+dz;
$.ajax({
type: "POST",
url: url,
data: data,
success: function(msg){
alert(msg);
testC.push(msg);
window.open("indexMap.jsp");
},
error:function (XMLHttpRequest, textStatus, errorThrown)
{
alert(textStatus);
}
});
}

对应的java:
String dz = (String)req.getParameter("dz");

这个代码在tomcat里面是好好的,可是转换到websphere里面“dz”的中文就全部变成了乱码????

请问该如何解决?急
...全文
223 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
kerisyml 2011-06-18
  • 打赏
  • 举报
回复
还是自己在网上找到的,在js里面转换两次data
chw8219 2011-06-17
  • 打赏
  • 举报
回复
试下:
var data="&trackType="+obj+"&slac="+slac+"&sid="+sid+"&sjd="+sjd+"&swd="+swd+"&dz="+encodeURI(dz);
fengyun817 2011-06-17
  • 打赏
  • 举报
回复
那就转换吧
String dz = new String(req.getParameter("dz").getBytes("iso-8859-1"),"gbk");
kerisyml 2011-06-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 fengyun817 的回复:]
JScript code

$.ajax({
type: "POST",
url: url,
contentType:"application/x-www-form-urlencoded;charset=utf-8",//这样呢?
data: data,
success: function(msg){
alert(msg);
testC.push(msg);
window.op……
[/Quote]

不行啊,依然是乱码???
fengyun817 2011-06-17
  • 打赏
  • 举报
回复

$.ajax({
type: "POST",
url: url,
contentType:"application/x-www-form-urlencoded;charset=utf-8",//这样呢?
data: data,
success: function(msg){
alert(msg);
testC.push(msg);
window.open("indexMap.jsp");
},

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧