這篇文章主要介紹了JSP怎么獲取Spring 注入對象,實現代碼如下,需要的朋友不要錯過
<%@ 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");
新聞熱點
疑難解答