当前位置:主页 > 查看内容

JSP 获取Spring 注入对象示例

发布时间:2021-06-12 00:00| 位朋友查看

简介:%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%%@ page import="org.springframework.context.ApplicationContext"%ServletContext sc = this.getServletConfig().getServletContext();ApplicationContext ac2 = We……
<%@ 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://m.jb51.net/article/52042.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文

  • 周排行
  • 月排行
  • 总排行

随机推荐