servlet中使用spring中的bean

代码如下

    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");
	}


你可能感兴趣的:(servlet中使用spring中的bean)