zoukankan      html  css  js  c++  java
  • url传递中文的解决方案

    By josh123456 发表于 2005-11-15 12:07:00

    url传递中文的解决方案
    1.设置web.config文件。(我不喜欢设置成这样)
    <system.web>
    ......
    <globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312" />
    ......
    </system.web>
    2.传递中文之前,将要传递的中文参数进行编码,在接收时再进行解码。
    >> 进行传递
    string Name = "中文参数";
    Response.Redirect("B.aspx?Name="+Server.UrlEncode(Name));
    >> 进行接收
    string Name = Request.QueryString["Name"];
    Response.Write(Server.UrlDecode(Name));

    3.如果是从 .HTML 文件向 .Aspx 文件进行传递中文参数的话(即不从后台用 Redirect()方法进行 Url 转换)。一样要将传递的中文参数进行编码,在接收时再进行解码。
    >> 进行传递
    <script language="JavaScript">
    function GoUrl()
    {
    var Name = "中文参数";
    location.href = "B.aspx?Name="+escape(Name);
    }
    </script>
    <body onclick="GoUrl()">
    >> 进行接收
    string Name = Request.QueryString["Name"];
    Response.Write(Server.UrlDecode(Name));

  • 相关阅读:
    清理iOS工程里无用的图片,可瘦身ipa
    NSTimer内存泄漏导致控制器不调用dealloc
    iOS面试题 -总结 ,你的基础扎实吗?
    Xcode找不到模拟器出现"My Mac"
    前端开发
    并发编程&数据库
    数据库
    4.2
    4.5
    4.4
  • 原文地址:https://www.cnblogs.com/allanyang/p/426325.html
Copyright © 2011-2022 走看看