• 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参数对数据进行的重新编码,不同的页面可以有不同的重新编码的编码


     

  • 相关阅读:
    c# winform 读取图片列表
    C# 枚举显示中文
    onenote网页版如何打开链接弄到客户端
    the error code is 2203
    unknown software exception
    无法读取配置节“protocolMapping”,因为它缺少节声明
    oracle 索引失效原因
    向 mysql 插入汉字时报错 Incorrect string value: 'xE6x9BxB9xE5x86xAC...' for col....
    (二)Linux——Linux常用指令
    (一)Linux——Linux基本概念
  • 原文地址:https://www.cnblogs.com/superch0054/p/4010076.html
Copyright © 2020-2023  润新知