Announcement Announcement Module
No announcement yet.
VelocityViewResolver and InternalResourceViewResolver Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • VelocityViewResolver and InternalResourceViewResolver

    Can anyone confirm that they are successfully using VelocityViewResolver and InternalResourceViewResolver (ie: for JSPs via JSTL) simultaneously - I'm having issues that the InternalResourceViewResolver always seems to be intercepting the resolution of the view and neither implement the Ordered inteface, so they can't be specified in a particular order:

    	<bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
    		<property name="cache" value="true"/>
    		<property name="prefix" value=""/>
    		<property name="suffix" value=".vm"/>
    	<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    	  	<property name="prefix" value="/WEB-INF/jsp/"/>
    		<property name="suffix" value=".jsp"/>
    As per suggestions in implementing the Ordered interface succeeds in forcing the VelocityViews to successfully resolve but JSP views fail as they are resolved to velocity template locations.

    The documentation (which still has incorrect references to being able to specify not existent "order" parameters on certain ViewResolvers) doesn't mention the two resolvers being incompatible.
    Last edited by robyn; May 14th, 2006, 07:28 PM.

  • #2
    Any resolver that extends from UrlBasedViewResolver will always return a View when asked to resolve a name. For this reason, you can't use two of them together for the reasons you've discovered.

    You will need to switch to either a ResourceBundleViewResolver or XmlViewResolver (both of which do implement the Ordered interface) either for all your views or for a subset, falling back to the JSP or Velocity one as required.



    • #3
      I was trying to avoid the need for one of ResourceBundleViewResolver or XmlViewResolver because of the extra configuration required.

      Thanks for your help.