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

来源:互联网 发布:网络小胖钱志君 编辑:程序博客网 时间:2024/05/21 11:06

首先导入包

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

原创粉丝点击