jsp访问web-inf下的spring配置文件

首先导入包

<%@ 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");

你可能感兴趣的:(jsp访问web-inf下的spring配置文件)