Webservice
// 获取Bean
MessageContext messageContext = context.getMessageContext();
ServletContext servletContext = (ServletContext) messageContext.get(MessageContext.SERVLET_CONTEXT);
WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext);
ITerminologyDownloadSrv downloadSrv = (ITerminologyDownloadSrv) applicationContext
.getBean("rhinTerminologyDownloadSrv");
Servlet中:
// 获取Bean
WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
ITerminologyDownloadSrv downloadSrv = (ITerminologyDownloadSrv) applicationContext
.getBean("rhinTerminologyDownloadSrv");
本文详细介绍了在Web应用中通过多种途径获取Bean实例的方法,包括使用MessageContext、ServletContext、WebApplicationContext等,以及如何在Servlet环境中实现Bean的获取。
3万+

被折叠的 条评论
为什么被折叠?



