Spring加載xml的方法

        //XmlBeanFactory   引用資源app

Resource resource = new ClassPathResource("appcontext.xml"); spa

BeanFactory factory = new XmlBeanFactory(resource); xml

 

//FileSystemXmlApplicationContext 文件系統的路徑資源

ApplicationContext factory1=new FileSystemXmlApplicationContext("classpath:appcontext.xml");get

 

//ClassPathXmlApplicationContext 編譯路徑servlet

ApplicationContext factory2=new ClassPathXmlApplicationContext("classpath:appcontext.xml"); it

 

//XmlWebApplicationContext  Web工程定製的io

ServletContext servletContext = request.getSession().getServletContext(); 編譯

ApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(servletContext ); class

相關文章
相關標籤/搜索