zoukankan      html  css  js  c++  java
  • 【SpringMVC】运行流程

    SpringMVC 运行流程

    在 Spring 的环境下使用 SpringMVC

    Bean 被创建两次 ? • Spring 的 IOC 容器不应该扫描 SpringMVC 中的 bean, 对应的 SpringMVC 的 IOC 容器不应该扫描 Spring 中的 bean

    <context:component-scan base-package="com.nemo.springmvc">
      <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
      <context:exclude-filter type="annotation" expression="org.springframework.stereotype.ControllerAdvice"/>
    </context:component-scan>
    <context:component-scan base-package="com.nemo.springmvc" use-default-filters="false">
      <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
      <context:exclude-filter type="annotation" expression="org.springframework.stereotype.ControllerAdvice"/>
    </context:component-scan>

    在 Spring MVC 配置文件中引用业务层的 Bean

    • 多个 Spring IOC 容器之间可以设置为父子关系,以实现良好的解耦。
    • Spring MVC WEB 层容器可作为 “业务层” Spring 容器的子容器:即 WEB 层容器可以引用业务层容器的 Bean,而业务层容器却访问不到 WEB 层容器的 Bean

  • 相关阅读:
    DHCP服务搭建
    JumpServer跳板机
    PXE
    DNS
    MySQL
    企业级LNMP分离式部署
    MHA-Atlas-MySQL高可用集群2
    MHA-Atlas-MySQL高可用集群
    备份全网服务器数据
    FTP
  • 原文地址:https://www.cnblogs.com/blknemo/p/13498279.html
Copyright © 2011-2022 走看看