response.setContentType() always trim the space between “; charset”?

两盒软妹~` 提交于 2019-12-12 08:56:05

问题


I'm using Tomcat 6.0.20, HttpServlet

my servlet code are as followings :-

response.setContentType("application/xml; charset=utf-8");

but each time i will got the content type as :

application/xml;charset=utf-8

which is without the space between " ; ".

May i know how to bypass the space being trimmed?

Is there anyway to do so (eg : modify the servet-api.jar)?


回答1:


It could be happening in Tomcat, in a reverse proxy in front of Tomcat, in a proxy, a firewall or somewhere in the client-side stack. It is probably impossible to stop whatever is doing this.

But it should not matter. The HTTP standard says that there is optional whitespace after the semicolon. Your client-side code should work whether the space is present or not.



来源:https://stackoverflow.com/questions/3438498/response-setcontenttype-always-trim-the-space-between-charset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!