在xml配置文件中

[SpringMVC]JSON乱码问题

 

 添加

    <!--JSON乱码问题-->
    <mvc:annotation-driven>
        <mvc:message-converters register-defaults="true">
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <constructor-arg value="UTF-8"/>
            </bean>
            <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                <property name="objectMapper">
                    <bean class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
                        <property name="failOnEmptyBeans" value="false"/>
                    </bean>
                </property>
            </bean>
        </mvc:message-converters>
    </mvc:annotation-driven>

即可解决JSON乱码问题

相关文章:

  • 2021-06-08
  • 2022-02-08
  • 2021-09-17
  • 2022-12-23
  • 2022-01-01
  • 2022-03-05
  • 2021-05-22
  • 2021-08-02
猜你喜欢
  • 2022-03-06
  • 2021-06-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
相关资源
相似解决方案