Solution:
Add the configuration <mvc:message-converters register-defaults=“true”>
in mvc:annotation-driven
of sprinmvc-servlet.xml
.
The codes are as below:
Unified solution to json Chinese messy code problem<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop
https://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!--springmvc 统一解决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>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
Read More:
- How to Solve the Primary Key of mybatisPlus Inserted Data is too Large Issue
- How to Solve Swagger Always Displays “basic-error-controller” Issue
- How to Solve JasperFillManager.fillReport Stuck issue (No Error and No Processing)
- Fastjson Error: Error: Cannot create inner bean ‘org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
- How to Solve IBM MQ Connect Error Code 2035
- [Solved] HttpMessageNotReadableException: JSON parse error: Unrecognized field “xxxx“
- OpenFeign Error: {“code“:1,“msg“:“JSON parse error: Illegal character ((CTRL-CHAR, code 31))
- [Solved] ssm Error: Error creating bean with name ‘employeeController’: Injection of autowired dependencies failed
- JAVA: How to Read JSON Format Data (Web Game Development)
- How to Solve Springboot YML configurate logging.level error
- [Solved] Feign Call Port Error: HttpMessageNotReadableException:JSON parse error:Illegal character ((CTRL-CHAR, code 31)
- How to Solve Tomcat Error: Could not resolve view with name ‘xxx/xxxxxxx‘ in servlet with
- How to Solve shiro Set sessionIdUrlRewritingEnabled Error (jessionid Removed)
- [Solved] org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot
- How to Solve Error-SpringCloud-Feign and Sentinel integrate error
- How to Solve zipkin Install Error in Windows
- How to Solve JDBC connection error in spring MVC integration
- How to Solve Error:java.io.InvalidClassException
- Weibo API api Called Error: error:appkey not bind domain! error_code:10017/2/statuses/share.json
- How to Download File via Response (Example Code)