I just started using Spring. I came across a lot tutorials.
I saw more examples using InternalResourceViewResolver
than UrlBasedViewResolver
. I looked
InternalResourceViewResolver
is infact subclass of UrlBasedViewResolver
.
UrlBasedViewResolver
- View name is directly resolved to an URL. No explicit mapping is provided. View name would be the URL itself or you can add a prefix
or suffix
as per your design. You can also prefix as "redirect:" and "forward:" to redirect and forward your request.
InternalResourceViewResolver
- Subclass of UrlBasedViewResolver that supports InternalResourceView. An InternalResourceView
wraps JSP or some other resource of the same web app. You can access models in the JSP using EL.
NOTE : Some URLBasedViewResolvers (Tiles, Velocity,Freemarker) check if resource exist and return null. So they can be anywhere in the view resolver chain. Others must be last (JSTL/JSP, XSLT, JSON)
So InternalResourceViewResolver
needs to be last in the chain of view resolvers since it resolves view name whether the actual resource is present or not.
Some other URLBasedViewReolver s are