zoukankan      html  css  js  c++  java
  • java -- 提交乱码汇总

    * 提交乱码
    * * GET :(参数在地址栏提交,地址栏也有自己的编码,默认是老外的iso-8859-1)
    * * 修改Tomcat默认字符集.(影响范围太大,可能影响大其他项目,不建议使用)
    * * URLEncoder和URLDecoder类进行(的就行2回)
    * * new String(s.getBytes("ISO-8859-1"),"UTF-8");
    * * POST :
    * * request对象的缓冲区默认是ISO-8859-1.
    * * request.setCharacterEncoding("UTF-8");(设置缓冲区的解码方式)
    * * 向页面输出中文:
    * * getOutputStream();
    * * response.getOutputStream().write("美美".getBytes());
    * * 不一定:
    * * getBytes();默认编码gbk.
    * getBytes("UTF-8");
    * * 浏览器打开的时候采用gbk打开.
    * response.setHeader("Content-Type","text/html;charset=UTF-8");
    * * getWriter(); --- 字符流缓冲区
    * * response.getWriter().println("美美");
    * * 一定会.
    * * response的缓冲区默认是ISO-8859-1的.
    * * 1.设置response的缓冲区的编码
    * response.setCharacterEncoding("UTF-8");
    * * 2.浏览器的打开方式的编码
    * response.setHeader("Content-Type","text/html;charset=UTF-8");
    * ***** response.setContentType("text/html;charset=UTF-8");

  • 相关阅读:
    acm python
    html cheatsheet
    unix cheatsheet
    liunx dd 读取系统文件
    比较文件内容是否相同
    linunx siege 安装
    数据库备份并压缩
    innobackupex xtrabackup 备份恢复mysql数据
    ubuntu安装rally
    解决Ubuntu显示中文乱码的问题
  • 原文地址:https://www.cnblogs.com/mr-level/p/4771008.html
Copyright © 2011-2022 走看看