1:
同一response对象, getWriter() 与 getOutputStream() 方法不能同时使用.
2:
response对象的setContentType设置编码text/html; charset=GBK时, 必须在getWriter之前,且
charset必须是小写的.
若在getWriter之后调用, 编码 GBK 是没有设置成功的.
这个方法可以设置头条目: Content-Type , 从而控制浏览器的使用指定编码来解析页面内容.
example:
Content-Type: text/html; charset=ISO-8859-4
HTTP/1.1 206 Partial content
Date: Wed, 15 Nov 1995 06:25:24 GMT
Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
Content-Range: bytes 21010-47021/47022
Content-Length: 26012
Content-Type: image/gif
3:
response对象的 setCharacterEncoding 才是设置编码的.
注意: 在流已经刷新或关闭与调用getWriter()之后, 调用 setCharacterEncoding 设置会失败.
4.
要想使用指定方言的编码,调用 setLocale 即可.
HTTP/1.1 协议:
[url]http://www.w3.org/Protocols/rfc2616/rfc2616.html[/url]
同一response对象, getWriter() 与 getOutputStream() 方法不能同时使用.
2:
response对象的setContentType设置编码text/html; charset=GBK时, 必须在getWriter之前,且
charset必须是小写的.
若在getWriter之后调用, 编码 GBK 是没有设置成功的.
这个方法可以设置头条目: Content-Type , 从而控制浏览器的使用指定编码来解析页面内容.
example:
Content-Type: text/html; charset=ISO-8859-4
HTTP/1.1 206 Partial content
Date: Wed, 15 Nov 1995 06:25:24 GMT
Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
Content-Range: bytes 21010-47021/47022
Content-Length: 26012
Content-Type: image/gif
3:
response对象的 setCharacterEncoding 才是设置编码的.
注意: 在流已经刷新或关闭与调用getWriter()之后, 调用 setCharacterEncoding 设置会失败.
4.
要想使用指定方言的编码,调用 setLocale 即可.
HTTP/1.1 协议:
[url]http://www.w3.org/Protocols/rfc2616/rfc2616.html[/url]