springMvc 国际化时乱码的解决办法

来源:互联网 发布:高中化学辅导书 知乎 编辑:程序博客网 时间:2024/06/05 20:13

springMvc 处理国际化是前台页面出现乱码,如下所示:
这里写图片描述

假设此时使用的是Session进行国际化(三种国际化都一样),解决办法:
1. 在 springMvc中配置:

    <!--国际化-->    <bean class="org.springframework.context.support.ResourceBundleMessageSource" id="resourceBundleMessageSource">        <!--国际化文件资源名-->        <property name="basename" value="messages"/>        <!-- 支持UTF-8的中文 -->        <property name="cacheSeconds" value="0"/>        <property name="defaultEncoding" value="UTF-8"/>    </bean>

2.修改 .properties配置文件的编码:

File ——> Settings --> Editor --> File Encodings下修改Default Encoding for properties files:为 UTF-8 即可。

3.进行正常的国际化编码

阅读全文
0 0
原创粉丝点击