spring mvc properties 中文乱码

来源:互联网 发布:网络招商代理 编辑:程序博客网 时间:2024/06/04 18:46

properties中加了配置,有中文,不设置一下的话,注入bean读出来的是乱码,是这样的:

{1,"֪ͨÊé±àºÅ"},{2£¬"ѧÉúÁбí"}

在spring-servlet.xml中设置一下编码格式就好了

<!--加载配置文件-->    <context:property-placeholder  location="classpath:config.properties" file-encoding="gb2312"/>  <!--注入导出类别类型-->    <bean id="exportType" class="com.normalClass.ExportType">        <property name="types" value="${config.export.type}"></property>    </bean>
public class ExportType {    private static String types;    public  void setTypes(String types) {        ExportType.types = types;    }    public static String getTypes() {        return types;    }}
0 0
原创粉丝点击