您的位置:首页 > 编程语言 > Java开发

servlet中使用spring中的bean

2014-04-23 15:18 190 查看
代码如下

private UploadHistoryTempManager uploadManager;
    
    @Override
	public void init() throws ServletException {
		super.init();
		ServletContext servletContext = this.getServletContext();  
	    WebApplicationContext wac = null;  
	    wac = WebApplicationContextUtils  
	            .getRequiredWebApplicationContext(servletContext);
	    uploadManager = (UploadHistoryTempManager) wac.getBean("uploadHistoryTempManager");
	}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: