|
【郑州校区】Spring在web开发中的应用 1.,在web项目中要使用spring需要导入一个jar包 2.在web.xml文件中配置Listener 这个ContextLoaderListener它实现了ServletContextListener 在这个listener中,当服务器启动时,将ApplicationContext对象,其实是它的一个实现类 WebApplicationContext,对象存入到了ServletContext中。 3.我们还需要在web.xml文件中配置applicationContext.xml文件的位置 默认情况下会在WEB-INF目录 下查找applicationContext.xmls 如果applicationContext.xml文件不是在默认位置,我们可以在web.xml文件中配置 Classpath:applicationContext.xml 它代表的是在当前工程的类路径下(可以理解成是在src)下来查找applicationContext.xml文件。 contextConfigLocation它是在listener中声明的一个常量,描述的就是spring配置文件的位置。 传智播客·黑马程序员郑州校区地址 河南省郑州市 高新区长椿路11号大学科技园(西区)东门8号楼三层 联系电话 0371-56061160/61/62 来校路线 地铁一号线梧桐街站A口出
|