天天看点

setContentType与setCharacterEncoding的区别1.setCharacterEncoding2.setContentType3.另外

setcharacterencoding只是设置字符的编码方式

setcontenttype除了可以设置字符的编码方式还能设置文档内容的·类型

输出:

setContentType与setCharacterEncoding的区别1.setCharacterEncoding2.setContentType3.另外

如果去掉<code>"&lt;!doctype html&gt; \n"</code>这一句的话

输出字体会变的没有任何格式

setContentType与setCharacterEncoding的区别1.setCharacterEncoding2.setContentType3.另外

浏览器的任何字体设置都没有用(前面带了<code>"&lt;!doctype html&gt; \n"</code>字体不一样是因为我设置了浏览器的个性化字体)

setContentType与setCharacterEncoding的区别1.setCharacterEncoding2.setContentType3.另外

完全和带了<code>"&lt;!doctype html&gt; \n"</code>的setcharacterencoding一样。

setcharacterencoding和setcontenttype只能在<code>response.getwriter();</code>之前才有用,如果是在这之后是没有任何作用的。

继续阅读