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;
}
}