日期:2014-05-17  浏览次数:20622 次

小弟是新号分数不高:我想问下关于showModalDialog模态窗口传值的问题,个位大神帮帮我
var url="style="+style;

var retval =window.showModalDialog("/joffice/customer/getSol.do?"+url,"",
"resizable:yes;scroll:yes;status:no;dialogHeight=255px;dialogWidth=375px;center=yes;help=no");

我的+url 中style是中文参数 传到action中就是乱码! 
我的action:String sol = new String(style.getBytes("iso-8859-1"),"utf-8");
           list = sdao.gethem(sol);
但是也不好使 
我要用window.open 就不会出现乱码问题!! 
怎么解决 求求个位了

------解决方案--------------------
encodeURI(url)
var retval =window.showModalDialog("/joffice/customer/getSol.do?"+encodeURI(url),"",
"resizable:yes;scroll:yes;status:no;dialogHeight=255px;dialogWidth=375px;center=yes;help=no");


action:
String sol = new String(URLDecoder.decode(request.getParameter("style"),"UTF-8"));


要是还不行!
在改改Web容器的server.xml中的URIEncoding
<Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" URIEncoding="UTF-8"/>

------解决方案--------------------
给段代码楼主参考参考:
var url = encodeURI('fawensearchRoles.action?tranName='+ tranName + "&processInstanceId=" + processInstanceId + "&fawenNumber=" + fawenNumber +"&fawenType=" + fawenType);
var obj = new Object();
obj = window.showModalDialog(url,window,"dialogWidth=500px;dialogHeight=400px");
其中参数tranName  传入的是中文,一切正常,没有出现乱码。
------解决方案--------------------
在客户端需要进行两次转码的。

var url = "page.do?param='大家好'";
url = encodeURI(encodeURI(url));
var obj = window.showModalDialog(url,...);
alert(obj.attribute);



后台伪代码:

String param = requset.getParameter("param"); 
param = URLDecoder.decode(param,"UTF-8");
sysout(param); // breakpoint