java类和servlet中访问spring中的bean
2012-02-04 16:18
369 查看
servlet 的访问spring中的bean:
ServletContext application=null;
WebApplicationContext wac=null;
application = getServletContext();
wac = WebApplicationContextUtils.getWebApplicationContext(application);
wac.getBean("bean的名字");
java 类访问spring 中的bean:
ApplicationContext context = new ClassPathXmlApplicationContext(
"com/appdev/gps/test-applicationContexts.xml");//路径从根目录下写起
context.getBean("bean的名字");
http://smartgwt.iteye.com/blog/1206720
ServletContext application=null;
WebApplicationContext wac=null;
application = getServletContext();
wac = WebApplicationContextUtils.getWebApplicationContext(application);
wac.getBean("bean的名字");
java 类访问spring 中的bean:
ApplicationContext context = new ClassPathXmlApplicationContext(
"com/appdev/gps/test-applicationContexts.xml");//路径从根目录下写起
context.getBean("bean的名字");
http://smartgwt.iteye.com/blog/1206720
相关文章推荐
- Servlet中访问spring容器管理的bean
- 在Servlet中可访问Spring bean对象,但是不能直接以注入的方式引用
- jsp+servlet+javabean && struts+spring+hibernate
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContex
- Spring Error creating bean with name 'sessionFactory ' defined in ServletContext resource [/WEB-INF/
- 普通Java类获取Spring的bean - traceofsun的专栏 - 博客频道 - CSDN.NET
- 在servlet中获取spring管理的bean
- 普通Java类获取Spring的Bean的方法
- 在servlet中得到spring注入的bean
- 非spring组件servlet、filter、interceptor中注入spring bean
- 解决servlet调用spring中bean的问题
- 在Servlet中使用spring注入的bean
- 为Servlet或普通Java程序注入Spring托管的Bean、数据源
- java类读取spring容器中的bean
- Thymeleaf:访问Spring中的bean
- spring和gwt整合,让gwt直接调用spring bean的前端servlet
- Spring强制向servlet中注入bean的方法
- HttpServlet获取Spring中托管的bean
- Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingH
- 项目中访问controller报错:HTTP Status 500 - Servlet.init() for servlet spring threw exception