PDA

View Full Version : Chaining Tiles and JSTL view



surya_vus
Nov 9th, 2006, 09:25 PM
When I try to have two view resolvers (Tiles and JSTL), I'm getting the following error



ERROR: DispatcherServlet [09 Nov 2006 19:17:25,499] : Context initialization failed
org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jstlView' defined in ServletContext resource [/WEB-INF/views.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'prefix' of bean class [org.springframework.web.servlet.view.JstlView]: Bean property 'prefix' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
Caused by:
org.springframework.beans.NotWritablePropertyExcep tion: Invalid property 'prefix' of bean class [org.springframework.web.servlet.view.JstlView]: Bean property 'prefix' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
at org.springframework.beans.BeanWrapperImpl.setPrope rtyValue(BeanWrapperImpl.java:751)

I'm using Spring 2.0 on Tomcat 5.5.20

Here is my configuration .

myapp-servlet.xml
------------------




<beans>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles.TilesCo nfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResou rceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.tiles.TilesVi ew"></property>
</bean>

<bean id="jstlViewResolver" class="org.springframework.web.servlet.view.XmlViewResolv er">
<property name="order" value="1" />
<property name="location" value="/WEB-INF/views.xml" />
</bean>
<beans>

views.xml
---------



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>
<bean id="jstlView" class="org.springframework.web.servlet.view.JstlView">
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>

Am I missing anything?

Thanks

ssquare
Nov 9th, 2006, 11:46 PM
I am not sure how to solve the complete issue, but the exception itself is pretty clear. The class org.springframework.web.servlet.view.InternalResou rceViewResolver has the prefix property, the JSTL View itself does not have prefix property, and that's what the excpetion is trying to tell you. I have not used Tiles with spring MVC so I can not tell you more details than that.