PDA

View Full Version : Can I set two InternalResourceViewResolver?



hairinwind
Dec 11th, 2006, 07:24 PM
Some pages are displayed in Tiles. so I have the setting

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
<property name="order" value="2" />
<property name="requestContextAttribute">
<value>rc</value>
</property>
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles.TilesJs tlView
</value>
</property>
</bean>

But I have some other pages which are not displayed in Tiles. So I have the setting below

<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>

But they cannot work together...Only the view for tiles can work.

I hope spring lookup in Tiles at first. If nothing matched, it will looup in jsp files. But it does not work as I wanted.

Please help!

davison
Dec 11th, 2006, 08:29 PM
you can't chain them together since they will always return a valid view name (even if the view itself is not valid). All UrlBased resolvers will do this.

You'll have to choose the one with fewest views and redefine it as a ResourceBundle resolver or an XML resolver.

hairinwind
Dec 12th, 2006, 04:05 PM
Thanks, it works!