java web.xml中加载顺序

web.xml中加载顺序是context-param -> listener -> filter -> servlet并不因在web.xml中配置顺序而改变


以自己的项目tdsTest为例
1.
首先读取web.xml中设置,根据<context-param> namecontextConfigLocation取相应的值,如

 <param-value>classpath:application.xml</param-value>

2.获取application.xml相应的设置,像这个project,就有import一个spring-mybatis.xml设置,然后初始化数据库相关配置

3. spring-mybatis.xml配置了数据库连接,mybatis印射的相关信息,从哪个地方去找mappermapper.xml,事务日志管理等

4.然后init DispatcherServlet,这里配置spring-mvc.xml servlet相关信息,比如自动扫描Controller,ServiceImpl,静态资源等

项目结构:

图片显示结构:



CallStack:

2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Wed Jul 19 19:11:30 CST 2017]; root of context hierarchy
2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [application.xml]
2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring/spring-mybatis.xml]
2017-07-19 19:11:30 [RMI TCP Connection(3)-127.0.0.1] INFO  com.alibaba.druid.pool.DruidDataSource - {dataSource-1} inited
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization completed in 913 ms
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization started
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.web.context.support.XmlWebApplicationContext - Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Jul 19 19:11:31 CST 2017]; parent: Root WebApplicationContext
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from class path resource [spring/spring-mvc.xml]
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/info/getCatJobInfo],methods=[GET]}" onto public java.util.List<com.ekin.test.bean.CatJobInfo> com.ekin.test.controller.CatJobInfoController.getCatJobInfo()
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Jul 19 19:11:31 CST 2017]; parent: Root WebApplicationContext
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Jul 19 19:11:31 CST 2017]; parent: Root WebApplicationContext
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/common/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#0'
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/css/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#1'
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/image/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#2'
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.web.servlet.handler.SimpleUrlHandlerMapping - Mapped URL path [/js/**] onto handler 'org.springframework.web.servlet.resource.ResourceHttpRequestHandler#3'
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/info/getCatJobInfo],methods=[GET]}" onto public java.util.List<com.ekin.test.bean.CatJobInfo> com.ekin.test.controller.CatJobInfoController.getCatJobInfo()
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerAdapter - Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Wed Jul 19 19:11:31 CST 2017]; parent: Root WebApplicationContext
2017-07-19 19:11:31 [RMI TCP Connection(3)-127.0.0.1] INFO  org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'dispatcher': initialization completed in 628 ms
2017-07-19 19:13:35 [http-apr-8080-exec-1] INFO  com.ekin.test.controller.CatJobInfoController - [com.ekin.test.bean.CatJobInfo@1e7aff31, com.ekin.test.bean.CatJobInfo@1d07f999]


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值