JSP_获取Spring_注入对象示例
来源:
中文源码网 浏览:200 次 日期:2024-05-13 20:05:01
【下载文档: JSP_获取Spring_注入对象示例.txt 】
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");