jsp访问web-inf下的spring配置文件
程序员文章站
2022-07-04 11:49:06
首先导入包
<%@ page import="org.springframework.web.context.support.WebApplicationCont...
首先导入包
<%@ page import="org.springframework.web.context.support.WebApplicationContextUtils" %>
<%@ page import="org.springframework.web.context.WebApplicationContext" %>
然后用下面的语句
WebApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());
GoodService goodService= (GoodService)wac.getBean("GoodService");