1.
public class HelloWorld {
private String msg;
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg() {
return msg;
}
public void detory(){
this.msg="";
}
}
<bean id="HelloWord" class="com.ltf.captha.serviceImpl.HelloWorld" destroy-method="destory">
<property name="msg">
<value>helloworld</value>
</property>
</bean>
2. 实现org.springframework.beans.factory.DisposableBean中的destory方法
public class HelloWorld implements DisposableBean{
private String msg;
public void setMsg(String msg) {
this.msg = msg;
}
public String getMsg() {
return msg;
}
public void destroy() throws Exception {
this.msg="";
} }