标签:style blog color io div sp on c log
1.init-method="init"
public class HelloWorldServiceImpl implements HelloWorldService { private String msg; public void init(){ this.msg="hellword"; } public void setMsg(String msg) { this.msg = msg; } public String getMsg() { return msg; } }
<bean id="HelloWorld" class="com.ltf.captha.serviceImpl.HelloWorldServiceImpl" init-method="init"> <property name="msg"> <value>helloworld</value> </property> </bean>
2.实现org.springframework.beans.factory.InitializingBean中的afterPropertiesSet
public class HelloWord implements InitializingBean{ private String msg; public void setMsg(String msg) { this.msg = msg; } public String getMsg() { return msg; } public void afterPropertiesSet() throws Exception { this.msg="hello"; } }
标签:style blog color io div sp on c log
原文地址:http://www.cnblogs.com/ltflike/p/3989016.html