目录
springmvc的执行流程,原理流程
简单总结 SpringMVC原理流程
tomcat日志详解
1.下面是tomcat全部日志,简单的我就不一一介绍了,重点讲解关键信息
服务器启动的时候做了什么 tomcat自检
服务器启动完之后做了什么
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server version: Apache Tomcat/8.5.38
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server built: Feb 5 2019 11:42:42 UTC
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Server number: 8.5.38.0
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Name: Windows 10
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: OS Version: 10.0
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Architecture: amd64
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Java Home: C:\Program Files\Java\jre1.8.0_73
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Version: 1.8.0_73-b02
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: JVM Vendor: Oracle Corporation
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_BASE: F:\WEB最终小项目\.metadata\.plugins\org.eclipse.wst.server.core\tmp2
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: CATALINA_HOME: F:\tomcat\apache-tomcat-8.5.38
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.base=F:\WEB最终小项目\.metadata\.plugins\org.eclipse.wst.server.core\tmp2
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dcatalina.home=F:\tomcat\apache-tomcat-8.5.38
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dwtp.deploy=F:\WEB最终小项目\.metadata\.plugins\org.eclipse.wst.server.core\tmp2\wtpwebapps
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Djava.endorsed.dirs=F:\tomcat\apache-tomcat-8.5.38\endorsed
五月 09, 2019 9:44:43 下午 org.apache.catalina.startup.VersionLoggerListener log
信息: Command line argument: -Dfile.encoding=GBK
五月 09, 2019 9:44:43 下午 org.apache.catalina.core.AprLifecycleListener lifecycleEvent
信息: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [C:\Program Files\Java\jre1.8.0_73\bin;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:/Program Files/Java/jre1.8.0_73/bin/server;C:/Program Files/Java/jre1.8.0_73/bin;C:/Program Files/Java/jre1.8.0_73/lib/amd64;C:\ProgramData\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Java\jdk1.8.0_73\bin;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;F:\apache-maven-3.5.0-bin\apache-maven-3.5.0\bin;C:\Users\Lenovo\AppData\Local\Microsoft\WindowsApps;;F:\eclipse\eclipse;;.]
五月 09, 2019 9:44:44 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-nio-8080"]
五月 09, 2019 9:44:44 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
五月 09, 2019 9:44:44 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-nio-8009"]
五月 09, 2019 9:44:44 下午 org.apache.tomcat.util.net.NioSelectorPool getSharedSelector
信息: Using a shared selector for servlet write/read
五月 09, 2019 9:44:44 下午 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1723 ms
五月 09, 2019 9:44:44 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service [Catalina]
五月 09, 2019 9:44:44 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/8.5.38
五月 09, 2019 9:44:44 下午 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom
警告: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [211] milliseconds.
五月 09, 2019 9:44:46 下午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
五月 09, 2019 9:44:46 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
五月 09, 2019 9:44:46 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
五月 09, 2019 9:44:46 下午 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization started
五月 09, 2019 9:44:46 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
信息: Refreshing Root WebApplicationContext: startup date [Thu May 09 21:44:46 CST 2019]; root of context hierarchy
五月 09, 2019 9:44:47 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [conf/spring.xml]
五月 09, 2019 9:44:47 下午 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization completed in 540 ms
五月 09, 2019 9:44:47 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring FrameworkServlet 'dispatcher'
五月 09, 2019 9:44:47 下午 org.springframework.web.servlet.DispatcherServlet initServletBean
信息: FrameworkServlet 'dispatcher': initialization started
五月 09, 2019 9:44:47 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
信息: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu May 09 21:44:47 CST 2019]; parent: Root WebApplicationContext
五月 09, 2019 9:44:47 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [conf/spring_mvc.xml]
五月 09, 2019 9:44:48 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping register
信息: Mapped "{[/user/login.do],methods=[POST]}" onto public org.springframework.web.servlet.ModelAndView com.tarena.controller.UserController.login(java.lang.String,java.lang.String)
五月 09, 2019 9:44:48 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
信息: Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu May 09 21:44:47 CST 2019]; parent: Root WebApplicationContext
五月 09, 2019 9:44:48 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
信息: Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu May 09 21:44:47 CST 2019]; parent: Root WebApplicationContext
五月 09, 2019 9:44:48 下午 org.springframework.web.servlet.DispatcherServlet initServletBean
信息: FrameworkServlet 'dispatcher': initialization completed in 1323 ms
五月 09, 2019 9:44:51 下午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
五月 09, 2019 9:44:51 下午 org.apache.jasper.servlet.TldScanner scanJars
信息: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
五月 09, 2019 9:44:51 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
五月 09, 2019 9:44:51 下午 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization started
五月 09, 2019 9:44:51 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
信息: Refreshing Root WebApplicationContext: startup date [Thu May 09 21:44:51 CST 2019]; root of context hierarchy
五月 09, 2019 9:44:51 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [conf/spring.xml]
五月 09, 2019 9:44:51 下午 org.springframework.web.context.ContextLoader initWebApplicationContext
信息: Root WebApplicationContext: initialization completed in 451 ms
五月 09, 2019 9:44:51 下午 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring FrameworkServlet 'dispatcher'
五月 09, 2019 9:44:51 下午 org.springframework.web.servlet.DispatcherServlet initServletBean
信息: FrameworkServlet 'dispatcher': initialization started
五月 09, 2019 9:44:51 下午 org.springframework.web.context.support.XmlWebApplicationContext prepareRefresh
信息: Refreshing WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu May 09 21:44:51 CST 2019]; parent: Root WebApplicationContext
五月 09, 2019 9:44:51 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [conf/spring_mvc.xml]
五月 09, 2019 9:44:52 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping register
信息: Mapped "{[/user/login.do],methods=[POST]}" onto public org.springframework.web.servlet.ModelAndView com.tarena.controller.UserController.login(java.lang.String,java.lang.String)
五月 09, 2019 9:44:52 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
信息: Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu May 09 21:44:51 CST 2019]; parent: Root WebApplicationContext
五月 09, 2019 9:44:52 下午 org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter initControllerAdviceCache
信息: Looking for @ControllerAdvice: WebApplicationContext for namespace 'dispatcher-servlet': startup date [Thu May 09 21:44:51 CST 2019]; parent: Root WebApplicationContext
五月 09, 2019 9:44:52 下午 org.springframework.web.servlet.DispatcherServlet initServletBean
信息: FrameworkServlet 'dispatcher': initialization completed in 909 ms
五月 09, 2019 9:44:52 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-nio-8080"]
五月 09, 2019 9:44:52 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-nio-8009"]
五月 09, 2019 9:44:52 下午 org.apache.catalina.startup.Catalina start
信息: Server startup in 8630 ms
1.信息: Initialization processed in 1723 ms
这是是tomcat自检 如果这行语句上面出现错误异常则表明,tomcat损坏, 读取tomcat本身的web.xml 里面包含(读取处理默认静态资源,设置session的生命周期,处理JSP页面,规定上传文件格式... 感兴趣自己可以打开tomcat去了解 )说明tomcat自检完毕无任何报错,
2.信息: Starting service [Catalina]
正在开启服务 名字为 [Catalina]
3.信息: Starting Servlet Engine: Apache Tomcat/8.5.38
正在开启servlet 引擎 开启引擎才可以扫描web项目 我的8.0tomcat出问题了 删了 mmp浪费好长时间 下了个8.5的版本 建议jdk和tomcat 版本一致 避免发生一些异常
4.信息: Initializing Spring root WebApplicationContext
读取web.xml配置文件 初始化spring的容器
5.信息: Loading XML bean definitions from class path resource [conf/spring.xml]
读取的目录在[conf/spring.xml]中的spring.xml里面的配置信息 如果没有这句话说明监听器出现问题 加载Spring容器
6.信息: Root WebApplicationContext: initialization completed in 540 ms
出现这句话证明spring容器正式启动成功
7.信息: Loading XML bean definitions from class path resource [conf/spring.xml]
dispatcher
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:conf/spring_mvc.xml
1
读取SpringMVC的配置文件,先创建框架架构,在创建springmvc子容器,!spring先创建在springMVC在创建
1.Tomcat启动的时候会自我检查,会自动读取本身的Web.xml文件,加载里面配置的信息,开启服务,开启引擎
2.开启引擎,并逐一扫描每一个Web项目的xml文件,并为其配置有且只有一个ServletContext
3.监听器读取Spring的配置文件,并初始化Spring容器
contextConfigLocation
classpath:conf/spring.xml
4.过滤器生命周期开始
org.springframework.web.context.ContextLoaderListener
5.DispatcherServlet(前端控制器)生命周期开始,
dispatcher
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:conf/spring_mvc.xml
1
@Controller
public class UserController {
//有此注解即可执行方法
@RequestMapping(value="user/login.do",method=RequestMethod.POST)
public ModelAndView login(String userName,String userPassword){
System.out.println(userName+" "+userPassword);
ModelAndView mav=new ModelAndView();
//假设此处调用业务,此处忽略业务
mav.addObject("key", "value");
//设置一个名称,用于springmvc拼装响应的url 前缀+success+后缀
mav.setViewName("success");
return mav;
}
}
6.tocmat启动完毕