读书人

spring 3中用注解后怎么直接取servlet

发布时间: 2012-10-30 16:13:36 作者: rapoo

spring 3中用注解后如何直接取servlet中取容器bean
在SPRING 3中,都用注解了,同样出现的问题是,比如要在servlet中去取得
容器中受spring管理的bean的方法,如何搞法,没了XML配置文件,其实方法很简单,
跟之前用XML时候是一样的,比如:

ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());

LeaveDao leavedao=(LeaveDao) context.getBean("leaveDao");

读书人网 >编程

热点推荐