spring 3中用注解后怎么直接取servlet中取容器bean
spring 3中用注解后如何直接取servlet中取容器bean
在SPRING 3中,都用注解了,同样出现的问题是,比如要在servlet中去取得
容器中受spring管理的bean的方法,如何搞法,没了XML配置文件,其实方法很简单,
跟之前用XML时候是一样的,比如:
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
LeaveDao leavedao=(LeaveDao) context.getBean("leaveDao");
在SPRING 3中,都用注解了,同样出现的问题是,比如要在servlet中去取得
容器中受spring管理的bean的方法,如何搞法,没了XML配置文件,其实方法很简单,
跟之前用XML时候是一样的,比如:
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
LeaveDao leavedao=(LeaveDao) context.getBean("leaveDao");