autoRequestEncoding 和 autoResponseEncoding

从 WebSphere® Application Server V5 开始,Web 容器不再自动设置请求和响应编码以及响应内容类型。程序员可以使用 Servlet 2.3 或更新版本规范中有效的方法设置这些值。 如果程序员选择不使用字符编码方法,那么他们可以指定 autoRequestEncodingautoResponseEncoding 扩展,其允许应用程序服务器设置编码值和内容类型。

autoRequestEncodingautoResponseEncoding 扩展的值为 truefalse。这两个扩展的缺省值为 false。如果 autoRequestEncodingautoResponseEncoding 的值都是 false,那么请求和响应字符编码会设置为“servlet 规范”的缺省值,即 ISO-8859-1。另外,如果为响应将该值设置为 false,那么 Web 容器不能设置响应内容类型。如果客户机在请求头中定义字符编码,或者如果代码包含 setCharacterEncoding(String encoding) 方法,那么可能会有不同的字符编码。

如果 autoRequestEncoding 值设置为 true,客户机没有在请求头中指定字符编码,并且此代码不包含 setCharacterEncoding(String encoding) 方法,那么 Web 容器会尝试为请求参数和数据确定正确的字符编码。

使用组装工具更改 autoRequestEncodingautoResponseEncoding 扩展的缺省值。

Web 容器执行以下列表中的每个步骤,直至找到匹配:

如果 autoResponseEncoding 值设置为 true,客户机没有在请求头中指定字符编码,并且此代码不包含 setCharacterEncoding(String encoding) 方法,那么 Web 容器执行以下操作:


指示主题类型的图标 概念主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=cweb_autoreq
文件名:cweb_autoreq.html