applicationContext.xml 配置文件的一些认识
存放位置: <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> 2:WEB-INF下面 <context-param> <param-name>contextConfigLocation</param-name> <param-value>WEB-INF/applicationContext*.xml</param-value> </context-param>
web.xml 通过contextConfigLocation配置spring 的方式 struts2的 1个+N个 路径:src+src(可配置) 名称: struts.xml + N spring的 配置文件在启动时,加载的是web-info目录下的applicationContext.xml, 配置web.xml使这2个路径一致: 多个配置文件的加载 <context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:conf/spring/applicationContext_core*.xml,classpath*:conf/spring/applicationContext_dict*.xml,classpath*:conf/spring/applicationContext_hibernate.xml,classpath*:conf/spring/applicationContext_staff*.xml,classpath*:conf/spring/applicationContext_security.xml classpath*:conf/spring/applicationContext_modules*.xml classpath*:conf/spring/applicationContext_cti*.xml classpath*:conf/spring/applicationContext_apm*.xml </param-value> </context-param> contextConfigLocation 参数定义了要装入的 Spring 配置文件。
首先与Spring相关的配置文件必须要以"applicationContext-"开头,要符合约定优于配置的思想,这样在效率上和出错率上都要好很多。 "**/"表示的是任意目录; <!-- Spring 的配置 -->
web.xml中classpath:和classpath*:,有什么区别?
classpath:只会到你的class路径中查找找文件; classpath*:不仅包含class路径,还包括jar文件中(class路径)进行查找. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |