页面几种处理中文乱码方法

来源:互联网 发布:中国钢材价格网软件 编辑:程序博客网 时间:2024/06/05 08:13

 

页面几种处理中文乱码方法

1,嵌套在js中用

 

window.location.href="http://localhost:8081/web/conObj/buyDetail.do?txt_conobj_key="+objKey+"&txt_contrade_kind="+CONTRADE_KIND+"&pick_types=A&jianjibuynum=0&order_prices="+orderPrice+"&cdListKeyArrayFront="+""+"&buyNum="+chatNum+"&ARTNFLAG="+ARTNFLAG+"&CNT_KEY="+CNT_KEY+"&msg="+encodeURIComponent(retMsg.msg);

encodeURIComponent($("#q").val())

 

 

 

Java后台转下

String query = request.getParameter("q");

query = new String(query.getBytes("ISO-8859-1"), "UTF-8");

 

2,嵌套在jsp中用

<%

   String file_name=java.net.URLEncoder.encode("日志信息列表.xls","UTF-8") ;

   response.setHeader("Content-disposition","attachment; filename="+file_name);

   //以上这行设定传送到前端浏览器时的档名为test1.xls

   //就是靠这一行,让前端浏览器以为接收到一个excel档 

%>

 

String MSG2 =URLDecoder.decode(msg, "utf-8");

0 0
原创粉丝点击