您的位置:首页 > 编程语言 > Java开发

JSP 获取Spring 注入对象示例

2014-07-09 00:00 585 查看
<%@ 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");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: