简体   繁体   English

Spring是否更改Content-Type的标题?

[英]Spring Changes Header for Content-Type?

I have a Spring and Jersey application and has that line: 我有一个Spring and Jersey应用程序,并且具有以下内容:

return Response.ok().header("Content-Type", "application/xml; charset=UTF-8").entity(restTemplate.postForObject(baseURL, entity, String.class)).build();

However when I debug at server side I see that Content-Type header is just application/xml. 但是,当我在服务器端调试时,我看到Content-Type标头只是application / xml。 Any ideas? 有任何想法吗?

You have to set a separate header with 您必须使用

.header("charset", "UTF-8")

Seems like Jersey is reading the header value only upto the semicolon . 似乎Jersey只能读取标题值,直到semicolon

However when I debug at server side I see that Content-Type header is just application/xml 但是,当我在服务器端调试时,我看到Content-Type标头只是application / xml

I am getting this in my code and during debug I can see the header which is proper. 我在代码中得到了这一点,在调试过程中,我可以看到正确的标题。

Please verify. 请验证。

I don't know but Sorry if I went wrong. 我不知道,但是抱歉,如果我做错了。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM