标签:servlet编码设置 setcharacterencoding setcontexttype
void setCharacterEncoding(java.lang.String charset)
setContentType(java.lang.String)
or setLocale(java.util.Locale)
,
this method overrides it. Calling setContentType(java.lang.String)
with the String
of text/html
and
calling this method with the String
of UTF-8
is
equivalent with calling setContentType
with the String
of text/html;
charset=UTF-8
.
This method can be called repeatedly to change the character encoding. This method has no effect if it is called after getWriter
has
been called or after the response has been committed.
上面是api的内容:
用法:setCharacterEncoding("UTF-8");
上述api的基本翻译如下:
给准备要发送到服务端响应对象response数据的MIME字符集编码进行设置,举个例子 UTF-8
如果setCharacterEnconding方法已经设置,会覆盖另外两种方法的设置。
setContentType("String
of text/html;
charset=UTF-8");
上面的解释道这两种设置方式是等价的。
另外如果这个方法在getWriter方法之后设置,或者在response对象已经提交之后设置,此方法就失效了。
servlet 发送到客户端的数据编码设置,布布扣,bubuko.com
标签:servlet编码设置 setcharacterencoding setcontexttype
原文地址:http://blog.csdn.net/hymking/article/details/25834707