In this section, you will learn about chaining of multiple view resolvers.
Spring supports multiple view resolvers and you can chain resolvers. And in some specific condition, you can override it. In your application context, you can chain view by adding more than one resolver to application context.
You can set view resolver's ordering in view resolver chain by setting order property. Keep in mind - higher the order priority, the later the view resolver is positioned in the chain. The InternalResourceViewResolver must always assign with the lowest priority because it will resolve the view whatever view name is returned.

In the given below example, three view resolvers, XmlViewResolver, ResourceBundleViewResolver, InternalResourceViewResolver contained by the chain and they have order 0,1,2 respectively :
<beans ...> <bean class="org.springframework.web.servlet.view.XmlViewResolver"> <property name="location"> <value>/WEB-INF/spring-views.xml</value> </property> <property name="order" value="0" /> </bean> <bean class="org.springframework.web.servlet.view.ResourceBundleViewResolver"> <property name="basename" value="spring-views" /> <property name="order" value="1" /> </bean> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" > <property name="prefix"> <value>/WEB-INF/pages/</value> </property> <property name="suffix"> <value>.jsp</value> </property> <property name="order" value="2" /> </bean> </beans>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: Chaining of Multiple view resolvers
Post your Comment