Announcement Announcement Module
No announcement yet.
XmlViewResolver and WebApplicationContext Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • XmlViewResolver and WebApplicationContext

    I am using XmlViewResolver and want to set a property on one of the beans in views.xml that is a reference to a bean in the WebapplicationContext.
    This does not seem to work. Is XMLViewResolver not context-aware?

    Can anyone suggest an alternate solution if there is no way to make the context available to beans in views.xml?


  • #2
    The XmlViewResolver uses an XML file to resolve its views. The XML file itself is indeed a BeanFactory, but doesn't have any links to other application contexts. You're better off using the BeanNameViewResolver, which resolves views wired up in your application context (basically the same as the XmlViewResolver, except for the fact that the context used is now hte webappctx).

    I guess you're aware of the fact that by using the contextConfigLocations init-param in your web.xml you can link in additional context files (might be handy if you need to spread the bean definitions, for example your views across multiple files).




    • #3
      Thanks for the info,
      I have decided to just use getWebApplicationContext() within the view to retrieve the bean for the time being.