<%WebApplicationContextwac=WebApplicationContextUtils.getRequiredWebApplicationContext(this
.getServletContext());
System.out.println("===========初始化成功=========");
worksService=(SomeServiceImpl)wac.getBean("someService");%>
spring部分代码:
StringattrName=WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE;//值为:
"org.springframework.web.context.WebApplicationContext.ROOT"
Objectattr=sc.getAttribute(attrName);
return(WebApplicationContext)attr;