user931501
user931501

Reputation: 91

Supporting UrlBasedViewResolver and TilesConfigurer and InternalResourceViewResolver

My project makes use of Spring Tiles nad I need to implement a plain jsp approach, so the project has a page that makes use of tiles and I want to incorporate a iframe that loads html so that I can refresh as needed. I thin I found my solution to implement the resolver to load an html file.

I have a consern about resolver conflicts. Has anyone combined a number of viewresolers in their app?

Upvotes: 1

Views: 3532

Answers (1)

Viral Patel
Viral Patel

Reputation: 8601

You can define multiple view revolvers in your spring configuration file and set an order to them.

<bean id="viewResolverTiles"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass">
        <value>org.springframework.web.servlet.view.tiles2.TilesView</value>
    </property>
    <property name="order" value="1" />
</bean>
<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"/>
  <property name="order" value="2"/>
</bean>

Note how we defined order property in both the view resolvers. Thus by default the Tiles based view resolver will be invoked. If Spring doesn't find view in that it moves to JSP view resolver.

Documentation: 16.5 Resolving views

I hope this helps.

Upvotes: 7

Related Questions