JSP 获取Spring 注入对象示例
JSP 获取Spring 注入对象示例
发布时间:2016-12-29 来源:查字典编辑
摘要:ServletContextsc=this.getServletConfig().getServletContext();Applicati...

<%@ 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");

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新JSP教程学习
热门JSP教程学习
编程开发子分类