简体   繁体   English

Spring MVC实现中的DI和IOC

[英]DI and IOC in spring mvc implementation

I am new to spring mvc and DI. 我是Spring MVC和DI的新手。 I have came to know about the flow of the spring project and i know how the web projects in spring mvc is developed and worked on few projects too. 我已经了解了Spring项目的流程,并且我知道Spring MVC中的Web项目是如何开发的,并且也可以在几个项目上工作。 All the annotation uses and xml configuration files in the spring mvc. Spring MVC中的所有注释使用和xml配置文件。 But i am confused where the DI is used? 但是我对使用DI的地方感到困惑吗? and how the DI is implemented in spring with the help of IOC?? 以及如何在IOC的帮助下在春季实施DI?

Can anyone please explain me the concept of DI and IOC and their implementation in spring mvc. 谁能解释一下DI和IOC的概念及其在Spring MVC中的实现。

Thanks in advance!!! 提前致谢!!!

DI and IOC happening through web.xml where you created the dispatcherservlet. DI和IOC通过在您创建调度程序servlet的web.xml中发生。 From Spring MVC docs : The DispatcherServlet, provides a shared algorithm for request processing while actual work is performed by configurable, delegate components The DispatcherServlet, as any Servlet, needs to be declared and mapped according to the Servlet specification using Java configuration or in web.xml. 来自Spring MVC文档:DispatcherServlet提供了一种用于请求处理的共享算法,而实际工作由可配置的委托组件执行。DispatcherServlet和任何Servlet一样,都需要根据Servlet规范使用Java配置或在Web中声明和映射。 XML。 In turn the DispatcherServlet uses Spring configuration to discover the delegate components it needs for request mapping, view resolution, exception handling, and more. 反过来,DispatcherServlet使用Spring配置发现请求映射,视图解析,异常处理等所需的委托组件。

internally it will register Spring mvc app and it will create an object and inject dependencies . 在内部它将注册Spring mvc应用程序,并且将创建一个对象并注入依赖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM