需知前提:


Spring是一个容器(会将所有的bean放在里面)(父容器)

{

Mapper代理对象、

Service对象、

SpringMVC容器(子容器)

     {Controller对象}

}

【Java】Spring、SpringMVC父子容器

父子容器特点:


子容器可以访问父容器对象(Controller可以注入Service),但是不能跨容器访问属性

父容器不能访问子容器中对象(Service不能注入Controller)

 

要想跨容器访问属性:

方法①:自己注入属性的配置文件

方法②:将注入的Service(Spring)中的属性“打开”(设置public以及get方法)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-23
  • 2021-09-20
  • 2021-12-11
  • 2021-08-28
  • 2021-10-24
  • 2021-08-04
猜你喜欢
  • 2022-01-15
  • 2021-07-14
  • 2021-06-12
  • 2021-08-06
  • 2021-05-15
相关资源
相似解决方案