Spring 为了将spring容器和对象的创建在服务器启动时创建(并且只创建一次),将其放在servletContext的监听器内执行。参数名contextConfigLocation哪里找?
2017-10-12 21:51
781 查看
Spring 为了将spring容器和对象的创建在服务器启动时创建(并且只创建一次),将其放在servletContext的监听器内执行。
servletContext的监听器(JSP三大组件之一 就是监听器):ContextLoaderListener。
spring封装了它。放在spring-web包下。可导入源码。
监听器这样配置的:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
【contextConfigLocation】属性。哪里找?
查看ContextLoaderListener源码寻找属性,发现其内部没有属性。
然后呢?这里涉及 查找源码小技巧。说起来很简单。
但是隔段时间不用总是会忘记,而且一时半会儿根本想不起来。尤其大脑疲惫的时候。。。
===【找不到成员属性或方法,就往上一层父类 或接口里找。】
参数名contextConfigLocation哪里找?
父类ContextListener找到了【contextConfigLocation】属性。
servletContext的监听器(JSP三大组件之一 就是监听器):ContextLoaderListener。
spring封装了它。放在spring-web包下。可导入源码。
监听器这样配置的:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
【contextConfigLocation】属性。哪里找?
查看ContextLoaderListener源码寻找属性,发现其内部没有属性。
然后呢?这里涉及 查找源码小技巧。说起来很简单。
但是隔段时间不用总是会忘记,而且一时半会儿根本想不起来。尤其大脑疲惫的时候。。。
===【找不到成员属性或方法,就往上一层父类 或接口里找。】
参数名contextConfigLocation哪里找?
父类ContextListener找到了【contextConfigLocation】属性。
相关文章推荐
- spring默认启动位置以及contextConfigLocation设置源码解析
- 详解contextConfigLocation|Spring启动过程详解(转)
- 手动创建(new)对象,使用spring容器中的bean(ServletContext)。
- (项目)Initializing Spring root WebApplicationContext ,服务器启动到这里就无法继续执行
- spring初级入门一(Spring介绍+启动Spring容器+Spring容器创建对象)
- spring默认启动位置以及contextConfigLocation设置源码解析
- spring启动时contextConfigLocation加载文件
- 详解contextConfigLocation|Spring启动过程详解
- spring in action 学习笔记三:对spring 容器的理解,以及如何利用AnnotationConfigApplicationContext这个容器创建对象
- 详解contextConfigLocation|Spring启动过程详解
- Spring boot源码分析-AnnotationConfigApplicationContext非web环境下的启动容器(2)
- Spring源码解析 – AnnotationConfigApplicationContext容器创建过程
- spring默认启动位置以及contextConfigLocation设置源码解析
- spring默认启动位置以及contextConfigLocation设置源码解析
- Spring-Spring容器启动各项操作窥探(AbstractApplicationContext#refesh()执行逻辑分析)
- spring项目中监听器作用-ContextLoaderListener与Tomcat容器中的ServletContextListener
- spring(IOC) 对象创建时机、对象作用域scope、对象的初始化方法和销毁方法的调用、spring容器总结
- Spring的核心之IoC容器创建对象
- spring 在启动服务器的时候报错 Could not open ServletContext resource [/WEB-INF/dispather-servlet.xml]
- SpringIOC容器-创建对象