如何在java中解析Json阿拉伯语文本

时间:2017-04-21 09:40:18

标签: java json spring-rest

我无法解析json arabic test。我正在json发送请求 {"SUBJECT_AR":"أهلا بك"}。但在 spring 中阅读此jsonobject时,我收到?????。发送请求时此jsonobject的内容类型为application/json;charset=utf-8。我已将produces="application/json;charset=utf-8"添加到其余控制器,即使它不起作用。

1 个答案:

答案 0 :(得分:0)

web.xmlweb-app标记内)中添加以下代码,然后重试:

<filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
        <param-name>forceEncoding</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>

<filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>