解决JS传参中文乱码

function PopupFK(cNum,type){
 	var url = "contract!Paying.action";
	url = url + "?contract.contractNum="+cNum+"&payingType="+type;
// if(isEmpty($(_this).attr("payId"))){
// url = url + "&s_paymentId="+paymentId;
// url = url + "&s_paymentDtlId="+paymentDtlId;
// }else{
// url = url + "&s_payId="+$(_this).attr("payId");
// }
	url = url+"&random="+Math.random();
     //在这里。用encodeURI进行两次转码。后台Action接收的时候。在进行一次。就不会出现乱码问题 url = encodeURI(url); url = encodeURI(url);   var ret = window.showModalDialog( url, "", "dialogWidth=950px;dialogHeight=600px;center=yes;border=thick;status=no;help=no;scrollbars=no" ); }
下面是Action代码片段
String cNum = contract.getContractNum();
		String Num;
		try {
			Num = URLDecoder.decode(cNum,"utf8");
			System.out.println(Num);
			c = csl.queryOneByNum(Num);
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException("合同数据错误,请联系管理员");
			
		}

  

你可能感兴趣的:(解决JS传参中文乱码)