关于contextconfiglocation的信息
contextconfiglocation怎么是使用全局
你在配置dispatcherServlet时,还是把contextConfigLocation删了吧。contextConfigLocation配置在两个地方context-param 2 param-value要想加载全部xml文件,在配置contextConfigLocation时,classpath:spring*.xml,*.xml这样配置。会简略一点。
关于ssm的web项目中contextConfigLocation的问题
联系是参数名一样...
区别是,前者由ContextLoaderListener监听器加载,后者由Servlet的init方法加载。
再直观点说:
监听器先于servlet加载。所以前者出现的时间点一定先于后者。
生命周期不同。所以前者通过ServletContext实例获取,后者通过ServletConfig实例或者Servlet的config属性获取。
Spring框架web.xml里几个位置的contextConfigLocation有什么不同?
效果一样的,都是用来指定bean的配置文件,不过写在一起要用逗号隔开。
spring contextconfiglocation不同地方有什么区别
加上init-param,参数为contextConfigLocation,直接告诉spring配置文件的位置。可以读入多个配置文件。
servlet
servlet-namemainServlet/servlet-name
servlet-classorg.springframework.web.servlet.DispatcherServlet/servlet-class
init-param
param-namecontextConfigLocation/param-name
param-value
classpath:config/applicationContext.xml,
classpath:config/base/base.xml,
classpath:config/base/datasource.xml,
classpath:config/base/aop.xml ...
/param-value
/init-param
load-on-startup1/load-on-startup
/servlet
servlet-mapping
servlet-namemainServlet/servlet-name
url-pattern*.do/url-pattern
/servlet-mapping
contextConfigLocation,属性
*代表匹配任意个数字符,
:前表示的是查找路径,classpath表示查找类的路径