JSP 获取Spring 注入对象示例
程序员文章站
2023-11-07 18:29:52
<%@ page import="org.springframework.web.context.support.webapplicationcontextu...
<%@ 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");
下一篇: 前几天小侄子拉肚子