Dispatcher-servlet.xml and application-context.xml

  • Why do we use the servlet.xml manager?
  • Is this something like web.xml?
  • Is the xmls application and manager different from each other, are there any similar things that can do?
  • I have a value, now do I need to send this to another class? I can do this through context.xml applications
+4
source share
3 answers
  • Since people do not want to use one of the most complex applications, context.xml, they separate them at the application level.

  • No, it's just a Spring application context file.

  • They do the same thing.

  • This is not what it is for; it is a determination of what your spring related objects will be introduced.

+3
source

In addition to Natans answer, dispatcher-servlet.xml defines the child context of the context of the underlying application (define in applicationContext.xml )

Contexts for children have access to all beans defined in the parent context, but parents do not have access to beans in child contexts.

+23
source
  • Dispatcher servlet.xml is just a convention, followed by the Spring front controller for MVC web applications. If you are not using Spring web MVC, you do not need to have dispatcher-servlet.xml
  • web.xml is the configuration file required by the Java web application. You must have web.xml for the Java web application, but Spring servlet.xml is only required if you are using Spring web MVC.
  • Spring XML Servlet is part of the Spring Web Application Configuration. You can put the entire Spring configuration in a single XML file if you want, but usually people have more than one.
  • Spring bean factory creates objects and introduces their dependencies. Your code does the rest. Define what it means to “send it to another class”.
+2
source

Source: https://habr.com/ru/post/1333604/


All Articles