JSP 获取Spring 注入对象示例说明
发布时间:2023-07-08 16:53:53 所属栏目:教程 来源:
导读:这篇文章主要介绍了JSP怎么获取Spring 注入对象,实现代码如下,需要的朋友不要错过
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%><%@ page import="org.springf
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%><%@ page import="org.springf
这篇文章主要介绍了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"); (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
站长推荐