| 发表于:2007-07-17 15:14:55 楼主 |
public class hellobean { private string helloword = "helloword!! "; private applicationcontext applicationcontext; public void sethelloword(string helloword){ this.helloword = helloword; } public string gethelloword(){ 27行: applicationcontext.publishevent(new propertygettedevent ( "[ "+helloword+ "] is getted ")); return helloword; } public void setapplicationcontext(applicationcontext context){ this.applicationcontext = context; } } public class propertygettedevent extends applicationevent { public propertygettedevent(object source){ super(source);; } } public class propertygettedlistener implements applicationlistener { public void onapplicationevent(applicationevent event) { system.out.println(event.getsource().tostring()); } } public class springtest { public static void main(string[] args){ applicationcontext context = new classpathxmlapplicationcontext( "bean.xml "); hellobean hello = (hellobean)context.getbean( "hellobean "); 35行: system.out.println(hello.gethelloword()); } } <beans> <bean id= "propertygettedlistener " class= "com.dl.bean.propertygettedlistener "/> <bean id= "hellobean " class= "com.dl.bean.hellobean "> <property name= "helloword "> <value> helloword!! </value> </property> </bean> </beans> 报这个异常 空指针 就是搞不懂 java.lang.nullpointerexception at com.dl.bean.hellobean.gethelloword(hellobean.java:27) at com.dl.test.springtest.main(springtest.java:35) exception in thread "main " |
|
|
|
|