Spring MVC response encoding issue

前端 未结 4 1656
醉酒成梦
醉酒成梦 2020-12-10 21:09

In last few hours I\'ve read a lot concerning this topic, and so far nothing has worked. I\'m trying to return response containing \"odd\" some characters. Here is example o

4条回答
  •  醉梦人生
    2020-12-10 21:40

    I can see two problems in the actual delivered response.

    • The response is clearly just text, but your response content-type header is saying it is HTML.

    • Judging from the content-length of the response, the content has not actually been encoded in UTF-8.


    FWIW - the CharacterEncodingFilter won't help with your problem because it is dealing with the encoding of the request not the response.


    I think that the problem is that you need to configure the message converter for the response body. However, it appears that your application already does something in this area, because the default behavior of the StringHttpMessageConverter is to use "text/plain" as its content type.

提交回复
热议问题