<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%> <%@ page import="org.springframework.context.ApplicationContext"%> ServletContext sc = this.getServletConfig().getServletContext(); ApplicationContext ac2 = WebApplicationContextUtils.getWebApplicationContext(sc);
要獲取的對象 serv = (要獲取的對象) ac2.getBean("spring配置文件中的id");
WebApplicationContext ctx = WebApplicationContextUtils.getRequiredWebApplicationContext((request).getSession().getServletContext());
AdvertiseService advertiseService = (AdvertiseService)ctx.getBean("advertiseService");
這個是在容器裡調 一個service的
你把這個方法寫哪裡了?發個log原句