PDA

View Full Version : integrating tiles with existing spring application


sawrav
Sep 11th, 2007, 05:36 PM
Hi ,
I am trying to integrate tiles with a existing spring application. the spring application is running smoothly. so when integrating tiles with it i have done the following changes:

My web.xml:

<servlet-mapping>
<servlet-name>myApp</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>

<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

index.jsp page:

<%@ include file="/jsp/include.jsp"%>
<a href="<c:url value="login.htm"/>">Login</a>

myApp-servlet.xml :

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

<bean id="viewResolver"
class="org.springframework.web.servlet.
view.InternalResourceViewResolver">

<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
</bean>

tiles-def.xml:

<tiles-definitions>
<definition name="template" page="/tiles/mainTemplate.jsp">
<put name="title" value="Default title"/>
<put name="header" value="/tiles/header.jsp"/>
<put name="companyName"
value="/tiles/companyName.jsp"/>
<put name="menu" value="/tiles/menu.jsp"/>
<put name="content"
value="/tiles/defaultContentPage.jsp"/>
<put name="footer" value="/tiles/footer.jsp"/>
</definition>

<definition name="login" extends="template">
<put name="title" value="Loging Page" />
<put name="content" value="/tiles/login.jsp"/>
</definition>
</tiles-definitions>

My LoginController:
return new ModelAndView("login","user", user);



previously, when i type http://localhost:8080/myApp/login.htm The login page was showing properly. to change the current application i have changed the login.jsp page location. now , when i am trying to type
http://localhost:8080/myApp/login.htm it throws "The requested resource (/myApp/login) is not available. "

Do i need to change any controller code ? I know this explanation looks messy, please let me know if you need any more information. I havent show the jsp pages as they are placed in the right place i guess. Looking for your reply

sawrav
Sep 13th, 2007, 01:02 PM
Oh i found the solution . I was using JSTLView instead of TilesView. When i changed that one to TilesView (InternalResourceViewResolver) the code is working properly. Thanks