JSP gets the sample Spring injection object
- 2020-12-19 21:09:00
- OfStack
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@ page import="org.springframework.context.ApplicationContext"%>
ServletContext sc = this.getServletConfig().getServletContext();
ApplicationContext ac2 = WebApplicationContextUtils.getWebApplicationContext(sc);
Object serv = (object to be fetched) ac2.getBean (" id" in the spring configuration file);