Contact

Technology

Dec 12, 2008

Chaining Spring View Resolvers

Credera Team

Credera Team

Default image background

Take this example of chaining view resolvers:

[code lang=”xml”]

[/code]

And this views.xml:

[code lang=”xml”]

[/code]

This should evaluate each view through the XmlViewResolver, then default back to the UrlBasedViewResolver if the XmlViewResolver does not find a view.

Now, let’s say we have the following tiles definition:

[code lang=”xml”]

[/code]

Looks pretty good.

Now, what if we, by coincidence, have this bean definition?

[code lang=”xml”]

[/code]

Uh oh. The XmlViewResolver will find the bean definition above (even though it’s not in the views.xml which was explicitly specified!), and give you this lovely error:

[code]org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named ‘forecastOverviewReport’ must be of type [org.springframework.web.servlet.View], but was actually of type [com.credera.forecasting.reporting.ForecastOverviewReport][/code]

But without the XmlViewResolver, this would have been perfectly fine. So, if you are chaining in an XmlViewResolver, make sure none of your tiles definition names are the same as any bean definition ids.

Conversation Icon

Contact Us

Ready to achieve your vision? We're here to help.

We'd love to start a conversation. Fill out the form and we'll connect you with the right person.

Searching for a new career?

View job openings