Take this example of chaining view resolvers:
<property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean id="jsonViewResolver" class="org.springframework.web.servlet.view.XmlViewResolver">
<property name="location" value="/WEB-INF/views.xml"/>
<property name="order" value="1"/>
</bean>
And this views.xml:
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:
<put-attribute name="pageHeader" value="Forecast Overview"/>
<put-attribute name="body" value="/WEB-INF/jsp/forecastOverviewReport.jsp"/>
</definition>
Looks pretty good.
Now, what if we, by coincidence, have this bean definition?
<property name="employeeDAO" ref="employeeDAO"/>
</bean>
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:
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.

Discussion
No comments yet.