Spring中如何设置boolean属性

几个要点:
配置文件 ftp.started=false

类:
//是否启动ftp任务
private boolean ftpStarted;

public String isFtpStarted() {
return ""+ftpStarted;
}

public void setFtpStarted(String ftpStarted) {
if (ftpStarted.equalsIgnoreCase("true")) {
this.ftpStarted = true;
}else {
this.ftpStarted = false;
}
}

spring配置文件:
<bean id="RcsFtpManager" class="com.feinno.security.rcs.rcsi.ftp.RcsFtpManager">
<property name="ftpStarted" value="${ftp.started}"/>
</bean>

原理很简单,spring设置后转化为内部boolean类型,有其他方法可交流,应该是比较笨的方法

猜你喜欢

转载自everlasting-188.iteye.com/blog/2231378