码迷,mamicode.com
首页 > Web开发 > 详细

url字符串编码乱码问题

时间:2016-05-24 09:14:50      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
 function webChart() {
            var t = document.getElementById("txtReceive");
            if (t.value == null || t.value == "") {
                alert("请先进行查询");
            }
            else {
              
                alert(t.value);
                document.getElementById("center-iframe").src = "map/industryMap.aspx?_indeustry=" + t.value;
}}
技术分享

这个时候alert出来的编码很正常,都是汉字。

技术分享

但是在后台获取时已经乱码

技术分享
        protected void Page_Load(object sender, EventArgs e)
        {
            Industry = Request.QueryString["_indeustry"].ToString();

            InitMap();
            getShowMuilt();
        }
技术分享

技术分享

 

web.config已经配置为UTF-8 但是还是不行

<system.web>
    <globalization culture="en-US" uiCulture="en" requestEncoding="UTF-8"
                   responseEncoding="UTF-8" fileEncoding="UTF-8" />
  </system.web>

 

 

最终解决方案

技术分享
 function webChart() {
            var t = document.getElementById("txtReceive");
            if (t.value == null || t.value == "") {
                alert("请先进行查询");
            }
            else {
                var url = encodeURI("map/industryMap.aspx?_indeustry=" + t.value);
                alert(url);
                document.getElementById("center-iframe").src = url;
}
}
技术分享

结果如下:

技术分享技术分享

url字符串编码乱码问题

标签:

原文地址:http://www.cnblogs.com/shouce/p/5522163.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!