zoukankan      html  css  js  c++  java
  • (转)请求参数的中文乱码问题

    首先实现这样一个页面

    在doGet和doPost中写入:

    输出的结果:

                  doGet : 乱码

                   doPost : 乱码

    解决方式:

    1、添加语句

    结果为: doGet :  乱码   

                     doPsot :  正确

    由此可以看出:request.setCharacterEncoding("UTF-8");这句在doGet方法中并不适用;

    修改方案:修改doget方法为:

           

    结果为:  doGet : 正确

                     doPost : 正确

    2、修改confserver.xml文件中的

     <Connector port="8080" protocol="HTTP/1.1" 

                   connectionTimeout="20000" 

                      redirectPort="8443"   />

      第一种:在末尾加上URIEncoding="UTF-8" ,然后运行检测

        结果:

                        doGet : 正确

                         doPost : 乱码

          由此可知这种方法不行

      第二种:在末尾加上useBodyEncodingForURI="true"

                           并在doGet()方法和doPost()方法中添加

      结果:  

             doGet :正确

              doPost: 正确

    转自 http://blog.csdn.net/redarmy_chen/article/details/6960938

  • 相关阅读:
    linux下shell显示-bash-4.1#不显示路径解决方法
    update chnroute
    An error "Host key verification failed" when you connect to other computer by OSX SSH
    使用dig查询dns解析
    DNS被污染后
    TunnelBroker for EdgeRouter 后记
    mdadm详细使用手册
    关于尼康黄的原因
    Panda3d code in github
    Python实例浅谈之三Python与C/C++相互调用
  • 原文地址:https://www.cnblogs.com/SamuelSun/p/4726102.html
Copyright © 2011-2022 走看看