编码和Servlet API:setContentType或setCharacterEncoding [英] Encoding and Servlet API: setContentType or setCharacterEncoding
本文介绍了编码和Servlet API:setContentType或setCharacterEncoding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
只是想知道幕后是什么.实际上,似乎我们可以通过以下方式设置编码:
Just wonder what is behind the scene. Actually it seems that we can set the encoding with:
-
response.setContentType("text/html; charset = UTF-8")
-
response.setCharacterEncoding("UTF-8")
有什么区别?
推荐答案
void setContentType(String type)
如果尚未提交响应,则设置要发送到客户端的响应的内容类型.给定的内容类型可以包括字符编码规范,例如text/html; charset = UTF-8
.
void setContentType(String type)
Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example,text/html;charset=UTF-8
.
这篇关于编码和Servlet API:setContentType或setCharacterEncoding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文