三叶草 发表于 2021-10-23 16:36:58

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


https://www.uoften.com/program/jsp/20180413/47808.html
页: [1]
查看完整版本: JSP 获取Spring 注入对象示例