22问答网
所有问题
怎么在servlet里面获取spring通过注解方式注入的service bean
如题所述
举报该问题
推荐答案 2017-02-11
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(session.getServletContext());
SessionService ss = wac.getBean(SessionService.class);
SessionService是自定义的service bean
温馨提示:答案为网友推荐,仅供参考
当前网址:
http://22.wendadaohang.com/zd/C0S6CSTCICSII60X2Ih.html
相似回答
如何在servlet取得spring
beans
答:
1- 将servlet作为bean定义在spring-context.xml文件中,和要应用的bean定义放在一起
;2- 实现一个代理servlet,该servlet用WebApplicationContext来获得在spring-context.xml中定义的servlet的对象,并将任务委托给spring-context.xml中定义的servlet 3- 在web.xml中用ContextLoaderListener来初始化spring 的con...
Servlet中
使用
注解
@Resource
注入service
,该
怎么
办
答:
首先:@ Service对应的是业务层Bean,将标注了此注解的类纳入进spring容器中管理
。做法如下:这样在Action里面userrService就可以用了。
大家正在搜
spring bean注入方式
spring注入bean注解
spring注解注入list
spring依赖注入注解方式
spring bean注解
spring基于注解注入
spring自动注入注解
spring注解注入原理
spring依赖注入注解