WEBService类中获取SpringIOC
MessageContext mc = MessageContext.getCurrentContext(); HttpServletRequest req = (HttpServletRequest) mc.getProperty(HTTPConstants.MC_HTTP_SERVLETREQUEST); ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(req.getSession().getServletContext()); QueryServiceImpl service = (QueryServiceImpl)ctx.getBean("queryService");
?
?
前提是需要在web.xml中已有加载spring IOC的配置,这样不管你配置文件放在什么位置都可以获取到了,