Reputation: 4176
I created Spring MVC with Tiles project.
My controller returns a string "hello" which is a logical file name and I have jsp called as hello.jsp.
In tiles.xml I should have a definition named hello which extends a definition template. My basic definition is mapped to layout.jsp.
When I add the jspViewResolver, it takes me to hello.jsp, but if I comment it out it takes me to layout.jsp which is rendered based on the definition of hello in tiles.xml.
So, why we shouldn't have both jspViewResolver and tilesViewResolver together?
Upvotes: 0
Views: 726
Reputation: 124898
Both the TilesViewResolver
and InternalResourceViewResolver
or instances instances of a UrlBasedViewResolver
. In general this means that the ViewResolver
takes the given view name and tries to construct a URL out of it this URL is used to resolve a view, regardless of the actual existence of the view.
Depending on the Spring version (Spring >= 3.0) and used subclasses a check will be done to check the actual existence of the view. (See this solved issue).
The only implementation not actually checking the existence of views (at the moment) it the InternalResourceViewResolver
or plain UrlBasedViewResolver
instances. When using this make this the last one (highest order
property) in the chain of view resolver.
When you want to combine plain JSP with Tiles this should actually be possible by giving the TilesViewResolver
an order of 1 and the InternalResourceViewResolver
an order higher then 1 (2 for instance).
In earlier versions (Spring < 3.0) these checks aren't in place and the ordering will as such not have any effect.
Upvotes: 1