WEB服务器之response

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]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值