?
?
?
只需要servlet 中的servletContext 对象作为参数 就可以获得spring中的bean对象,方法如下:
?
public static Object getBean(String name, ServletContext context) { WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(context); return ctx.getBean(name); }?