Announcement Announcement Module
Collapse
No announcement yet.
Utility of ContextLoaderListener ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Utility of ContextLoaderListener ?

    Hy, Im a beginner with spring and I have read about the ContextLoaderListener to use it in the web.xml file in a web application. But
    I still dont know what is this for, I lie, I think is a listener for an event but what event?.
    In my controller, for example, I still have to create a WebXMLApplicationContext, so I dont unsterstand the utility of this.
    Wont i have to implement something in this listener to respond for a such event, the behaviour of the listeners are made for this, right?

    Thanks

  • #2
    Originally posted by gogofe View Post
    Hy, Im a beginner with spring and I have read about the ContextLoaderListener to use it in the web.xml file in a web application. But
    I still dont know what is this for, I lie, I think is a listener for an event but what event?.
    ContextLoaderListener is an implementation of javax.servlet.ServletContextListener, which listen for standard Java Servlet container(server) start and stop of the webapp you are writing. The Spring ContextLoaderListener listens and load a Spring context when your webapp starts.

    In my controller, for example, I still have to create a WebXMLApplicationContext, so I dont unsterstand the utility of this.
    Wont i have to implement something in this listener to respond for a such event, the behaviour of the listeners are made for this, right?
    Thanks
    I am not sure what WebXMLApplicationContext is. you would need to specify the full path if it's from Spring.

    In general, a SpringMVC is form by creating one or more org.springframework.web.servlet.DispatcherServlet servlet and it's mapping, which each will loads a Spring Application Context that ends in <servlet-name>-servlet.xml. In addition, SpringMVC allows you to add one more root/sharable applicationContext which configure and loaded by a servlet context listener ContextLoaderListener.

    If these are confusing to you, you need to read Spring Ref doc(see chap 13).

    Comment

    Working...
    X