Java Spring@response body使用不同的字母返回错误结果

Java Spring@response body使用不同的字母返回错误结果,java,spring,httpresponse,Java,Spring,Httpresponse,我有一个使用@responsebody注释的spring方法,只要resonse主体 希伯来语字母客户端显示的响应是扭曲的。我将StringHttpMessageConverter字符集更改为utf-8,但结果仍然相同 我能做什么 @RequestMapping(method = RequestMethod.POST, value = {"/{accountID}/{containerID}/{objectID:.+}"}) public

我有一个使用@responsebody注释的spring方法,只要resonse主体 希伯来语字母客户端显示的响应是扭曲的。我将StringHttpMessageConverter字符集更改为utf-8,但结果仍然相同

我能做什么

 @RequestMapping(method = RequestMethod.POST,  
                    value  = {"/{accountID}/{containerID}/{objectID:.+}"})
    public @ResponseBody String createObject( @PathVariable String accountID, 
                                              @PathVariable String containerID, 
                                              @PathVariable String objectID, 
                                              HttpServletRequest   request, 
                                              HttpServletResponse  response)



<mvc:annotation-driven>
<!-- register custom converter that returns UTF-8 encoded response-body by defualt -->
    <mvc:message-converters register-defaults="true">
        <bean class="org.springframework.http.converter.StringHttpMessageConverter">
            <constructor-arg index="0" name="defaultCharset" value="UTF-8"/>
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>
@RequestMapping注释应定义属性生成:


否则,它会使用服务器的默认编码,不一定是UTF-8。

发现了问题所在,响应内容长度没有考虑特殊字符的大小,一旦我为特殊字符添加了额外的空间,客户端上的结果就如预期的那样。

我也尝试过,仍然没有运气。此外,我还看到StringHttpMessageConverter使用utf-8作为其字符。首先,在通过HTTP发送之前,请确保您的内容未被破坏。例如,输入硬编码的内容。如果它不能正常工作,检查客户端发生了什么。例如,使用ChromeDeveloper工具查看服务器发送的HTTP头。
@RequestMapping(method = RequestMethod.POST,  
                value  = {"/{accountID}/{containerID}/{objectID:.+}"}, , 
                produces = "text/plain;charset=UTF-8")