摘要: spring实例化bean有两种方式,第一种是通过配置文件注入,例如(这里只介绍通过setter方式)如果有多个bean需要依赖的话,则需要这么写: 接下来就要编写实现类了:public class A { private B b; public B getB() { return b; } public void setB(B b) { this.b = b; } public void out(){ b.out(); }}public class B { public void out(... 阅读全文
posted @ 2013-09-13 17:48 s413574930 阅读(186) 评论(0) 推荐(0) 编辑
摘要: spring的配置文件applicationContext.xml的位置是任意的,可以放在classpath下也可以放在webContent下,只需要在web.xml中配置即可例如:在webContent中则 1 2 contextConfigLocation 3 /WEB-INF/applicationContext.xml 4 5 6 7 8 9 org.springframework.web.context.ContextLoaderListener 10 在classPath下则:注意要添加classPath ... 阅读全文
posted @ 2013-09-13 14:29 s413574930 阅读(86) 评论(0) 推荐(0) 编辑