zoukankan      html  css  js  c++  java
  • URIEncoding与useBodyEncodingForURI 在tomcat中文乱码处理上的区别

    大家知道tomcat5.0开始,对网页的中文字符的post或者get,经常会出现乱码现象。

    具体是因为Tomcat默认是按ISO-8859-1进行URL解码,ISO-8859-1并未包括中文字符,这样的话中文字符肯定就不能被正确解析了。

    常见的解决方法是在tomcat的server.xml下的connetor属性中增加URIEncoding或者useBodyEncodingForURI属性。

    但是,这两种方式有什么区别呢?

    我简单谈一下自己的理解:

    按照tomcat-docs/config/http.html文档的说明

    URIEncoding:This specifies the character encoding used to decode the URI bytes, after %xx decoding the URL. If not specified, ISO-8859-1 will be used.

    useBodyEncodingForURI:This specifies if the encoding specified in contentType should be used for URI query parameters, instead of using the URIEncoding.

    也就是说,

     useBodyEncodingForURI参数表示是否用request.setCharacterEncoding 
    参数对URL提交的数据和表单中GET方式提交的数据进行重新编码,在默认情况下,该参数为false。

    URIEncoding参数指定对所有GET方式请求进行统一的重新编码(解码)的编码。

    URIEncoding和useBodyEncodingForURI区别是,

    URIEncoding是对所有GET方式的请求的数据进行统一的重新编码,

    而useBodyEncodingForURI则是根据响应该请求的页面的request.setCharacterEncoding参数对数据进行的重新编码,不同的页面可以有不同的重新编码的编码

    原文地址:https://www.cnblogs.com/itcomputer/p/4788052.html
  • 相关阅读:
    洛谷P2504 [HAOI2006]聪明的猴子
    洛谷P1516 青蛙的约会
    洛谷P1991 无线通讯网
    洛谷P1265 公路修建
    可展开的列表组件
    网格视图(GridView)功能和用法
    自动完成文本框的功能和用法
    扩展BaseAdapter实现不存储列表项的ListView
    使用SimpleAdapter创建ListView
    实例:基于ListActivity实现列表
  • 原文地址:https://www.cnblogs.com/jpfss/p/12111571.html
Copyright © 2011-2022 走看看