zoukankan      html  css  js  c++  java
  • url传中文参数的时候,乱码,需要对web.config配置

    1,form表单提交到某个具体页面

    <form id="search_form" name="search_form"  target="_blank" method="Post">    
                <input id="catid" name="catid" type="hidden" value="0"/>
                    <input class="sb" type="submit" value="" onclick="return get()"/>
                      <script type="text/javascript">
                        function get()
                        {
                            if(document.getElementById("q").value=="")
                            {
                                alert("请输入搜索关键词!");
                                return false;
                            }
                            else
                            {
                                var type=document.getElementById("catid").value;
                     //中文编码的时候需要对参数编码 //var search=encodeURI(document.getElementById("q").value); //UTF-8的时候需要对参数进行编码 var search=document.getElementById("q").value;//gb2312的时候可以直接传参数 document.getElementById('search_form').action="/zhuanti/SubJectBrandSearch_"+type+"_"+search+"_1.html"; document.search_form.submit(); } } </script> </form>

     2.后台接收数据

    //关键词解码,需要web.config配置gb2312编码格式
                Keyword = HttpUtility.UrlDecode(Function.SqlFilter(DtRequest.GetString("Key", true).ToString()));
    

    3.web.config里面的配置

    system.web 加上这一句,明确是什么编码
    <globalization requestEncoding="gb2312" responseEncoding="gb2312" culture="zh-CN" fileEncoding="gb2312"/>
    

      

    你将独自前行,你会遇到友好,也会遇到恶意,不管你多么善良,因为世间就是这样,不好,不坏.
  • 相关阅读:
    02-最简C语言程序
    Go学习笔记-GO编程语言手册
    Go学习笔记-Effective Go
    go学习笔记-语法
    机器学习-数据挖掘
    windows下jupyter notebook的安装及配置
    wpf学习笔记
    windows下安装mingW及控制台启用
    nginx
    MFC学习笔记
  • 原文地址:https://www.cnblogs.com/jsdvkm/p/4600571.html
Copyright © 2011-2022 走看看