最近在用ECharts+echarts java搞数据统计。
先建了独立项目测试没问题,然后转移到工作项目内,却出现乱码,所有中文都为???
对比发现前后台都为UTF-8编码,后台数据也正常,为啥到前台就乱码了?
对比发现spring mvc配置文件没有
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean>
<bean
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>赶快加上果然解决。。

本文详细介绍了在使用ECharts+echartsjava进行数据统计时,将独立项目中的测试成功迁移至工作项目后,中文出现乱码的问题。通过对比发现,后台数据正常且编码统一为UTF-8,问题在于Spring MVC配置文件中未正确配置消息转换器,导致前台显示乱码。解决方案是在Spring MVC配置文件中添加相应的消息转换器配置,使得中文能够正确显示。
1256

被折叠的 条评论
为什么被折叠?



