Spring-Spring MVCNo Comments

In Spring MVC application, often times, you may applying few view resolver strategies to resolve the view name. For example, combine three view resolvers together : InternalResourceViewResolver, ResourceBundleViewResolver and XmlViewResolver.

But, if a view name is returned, which view resolver strategy will be used?

Answer

If multiple view resolver strategies are applied, you have to declare the priority through “order” property, where the lower order value has a higher priority, for example :

Now, if a view name is returned, the view resolving strategy works in the following order :

Note
The InternalResourceViewResolver must always assign with the lowest priority (largest order number), because it will resolve the view no matter what view name is returned. It caused other view resolvers have no chance to resolve the view if they have lower priority.

Check my Spring MVC- View Resolver post to see another ways of view resolvers.


Be the first to post a comment.

Add a comment