首页 > 编程 > JSP > 正文

JSP 获取Spring 注入对象示例

2019-11-02 15:51:17
字体:
来源:转载
供稿:网友

 这篇文章主要介绍了JSP如何获取Spring 注入对象,实现代码如下,需要的朋友不要错过

   
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%><%@ page import="org.springframework.context.ApplicationContext"%>ServletContext sc = this.getServletConfig().getServletContext();ApplicationC
安安阁影院[www.aikan.tv/special/anangeyingyuan/]
ontext ac2 = WebApplicationContextUtils.getWebApplicationContext(sc);

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

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表