首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

servlet 中取得spring Bean 的方法

2012-08-21 
servlet 中获得spring Bean的方法???只需要servlet 中的servletContext 对象作为参数 就可以获得spring中

servlet 中获得spring Bean 的方法

?

?

?

只需要servlet 中的servletContext 对象作为参数 就可以获得spring中的bean对象,方法如下:

?

public static Object getBean(String name, ServletContext context) {        WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context);        return ctx.getBean(name);    }
?

热点排行