zoukankan      html  css  js  c++  java
  • HTTP 浏览器发送给服务器的数据编码问题

    doget方式  由于传输数据不是在实体内容中 ,解码 需要使用手动 解码!

    /**
    * 手动重新解码(iso-8859-1 字符串-> utf-8 字符串)
    */
    /*if("GET".equals(request.getMethod())){
    name = new String(name.getBytes("iso-8859-1"),"utf-8");
    }*/
    
    String password = request.getParameter("password");
    
    /*if("GET".equals(request.getMethod())){
    password = new String(password.getBytes("iso-8859-1"),"utf-8");
    }*/

    dopost方式 :

    request.setCharacterEncoding("utf-8");

    不推荐方式:  直接改 tomcat服务器配置文件 ,这样无须改代码

    tomcat目录下-------- conf ----------- server.xml

    <Connector port="8080" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443"    URIEncoding="utf-8" />

  • 相关阅读:
    c++ ::和:
    c++ extern
    c++ cpp和hpp
    c++ include
    caffe调试
    caffe blob理解
    poj3126
    FFmpeg滤镜使用指南
    Android之Activity之间传递对象
    Server Tomcat v8.0 Server at localhost failed to start.
  • 原文地址:https://www.cnblogs.com/yimian/p/7017480.html
Copyright © 2011-2022 走看看