亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

java - SpringMVC@ResponseBody中文亂碼
PHP中文網(wǎng)
PHP中文網(wǎng) 2017-04-18 10:42:03
0
6
813
PHP中文網(wǎng)
PHP中文網(wǎng)

認(rèn)證0級(jí)講師

reply all(6)
小葫蘆

Just add this to the xml file
<mvc:annotation-driven>

    <mvc:message-converters register-defaults="true">
        <bean class="org.springframework.http.converter.StringHttpMessageConverter">
            <property name="supportedMediaTypes" value="text/html;charset=UTF-8"></property>
        </bean>
    </mvc:message-converters>
</mvc:annotation-driven>
左手右手慢動(dòng)作

I don’t know what MediaType is, but I have always used the encoding produces = "application/json;charset=UTF-8", or the front-end encoding is not utf-8

黃舟

If the server is Tomcat, change to version 8.0 or above. Older versions did not encode UTF-8 by default.

左手右手慢動(dòng)作

Configure a spring encoding filter
I searched for one for reference
If it is a new project, check out spring boot. Basically, there is no need to configure it. Things like Chinese garbled characters are all configured by default.

阿神

Let’s talk about the garbled code problem GET and POST
POST configure the spring filter in the web. URIencoding=utf-8 or take it and use ISO-8859-1 to manually decode it and then encode it in UTF-8

Peter_Zhu

Configuring a simple CharacterFilter may not solve the problem. If you are using Jackson2, try the following solution

<mvc:annotation-driven>
        <mvc:message-converters>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="supportedMediaTypes">
                    <util:list>
                        <value>application/json;charset=UTF-8</value>
                        <value>text/html;charset=UTF-8</value>
                    </util:list>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>

Jackson1 is the same, but the class is changed to MappingJacksonHttpMessageConverter

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template