当有http请求时,web容器根据web.xml中的url-pattern找到对应的SpringMVC入口Servlet:org.springframework.web.servlet.DispatcherServlet,DispatcherServler取得其配置文件xml中定义的context:component-scan即controler的包路径。若是通过注解,需在xml中设置annotation-config,这样SpringMVC框架就会读取controler包内的java文件,以@controler注解的就是controler,@requestmapping注解的就是具体的url映射。通过@autowired就是注入,contrloller再读取具体有@service(业务层),@repository(持久层),@component(组件层)注解的下级对象。