Announcement Announcement Module
Collapse
No announcement yet.
Retrieving applicationContext Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Retrieving applicationContext

    Hi

    I noticed that there is an 'XmlWebApplicationContext' instance stored as a servletContext attribute which has a key of 'interface org.springframework.web.context.WebApplicationCont ext.ROOT'. This object contains my beans which were defined in the applicationContext.xml.

    Is there a standard/preferred way to retrieve the applicationContext from within the web tier in a spring mvc webapp?

    Jim

  • #2
    try


    Code:
    WebApplicationContext ctx =RequestContextUtils.getWebApplicationContext(request);
    
    ctx.getBean("name")

    Comment


    • #3
      Is there a similar way of retrieving a BeanFactory defined in an application, for example in the file 'someFancy-servlet.xml'?

      Comment

      Working...
      X