zl程序教程

您现在的位置是:首页 >  后端

当前栏目

JSP获取Spring注入对象示例

SpringJSP注入对象 获取 示例
2023-06-13 09:15:37 时间
<%@pageimport="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@pageimport="org.springframework.context.ApplicationContext"%>

ServletContextsc=this.getServletConfig().getServletContext();
ApplicationContextac2=WebApplicationContextUtils.getWebApplicationContext(sc);

要获取的对象serv=(要获取的对象)ac2.getBean("spring配置文件中的id");