一
Spring是一個輕量級的控制反轉(IoC)和面向切面(AOP)的容器框架
二
方法一
代碼
ApplicationContext ac =
new
FileSystemXmlApplicationContex(
applicationContext xml
);
ac getBean(
beanId
);
ApplicationContext ac = new FileSystemXmlApplicationContex(
ac
方法二
代碼
import
org sprntext support WebApplicationContextUtils;
ApplicationContext ac = WebApplicationContextUtils
getRequiredWebApplicationContext(ServletContext sc)
ApplicationContext ac = WebApplicationContextUtils
getWebApplicationContext(ServletContext sc)
ac getBean(
beanId
);
ac getBean(
beanId
);
import
org sprntext support WebApplicationContextUtils;
ApplicationContext ac = WebApplicationContextUtils
getRequiredWebApplicationContext(ServletContext sc)
ApplicationContext ac = WebApplicationContextUtils
getWebApplicationContext(ServletContext sc)
ac getBean(
beanId
);
ac getBean(
beanId
);
方法三
說明
方法四
說明
方法五
說明
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28587.html