Order of loading contextConfigLocation in web.xml of Spring Servlet project

前端 未结 4 481
栀梦
栀梦 2020-12-13 00:00

Suppose that I have a Spring Java project and I am trying to configure it as a web server servlet. Here is a stripped-down version of the web.xml f

4条回答
  •  不思量自难忘°
    2020-12-13 00:10

    The below part loads the context file and create the ApplicationContext. This context might, for instance, contain components such as middle-tier transactional services, data access objects, or other objects that you might want to use (and re-use) across the application. There will be one application context per application.

    
        contextConfigLocation
        
            /WEB-INF/spring/generalApplicationContext.xml
        
    
    

    The other context is the WebApplicationContext which is the child context of the application context. Each DispatcherServlet defined in a Spring web application will have an associated WebApplicationContext. The initialization of the WebApplicationContext happens like this:

    
        my-servlet
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            /WEB-INF/spring/specificApplicationContext.xml
        
        1
    
    

    For more details refer this and this

提交回复
热议问题