Servlet中访问spring容器管理的bean

来源:互联网 发布:淘宝买家情趣内衣秀 编辑:程序博客网 时间:2024/05/29 05:08

条件:使用框架为springMVC

import javax.servlet.http.HttpServlet;import org.springframework.context.ApplicationContext;import org.springframework.web.context.support.WebApplicationContextUtils;public class EsayServlet extends HttpServlet{@Overridepublic void init(){ApplicationContext ac= WebApplicationContextUtils.getRequiredWebApplicationContext(this.getServletContext());ac.getBean("");}}


0 0