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;
}
}
转载请注明原文地址: https://ju.6miu.com/read-962435.html