JSP 获得Spring 注射对象

it2025-07-11  5

<%@ 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.cnblogs.com/bhlsheji/p/5038087.html

相关资源:JSP 获取Spring 注入对象示例
最新回复(0)