Announcement Announcement Module
Collapse
No announcement yet.
Tiles are not displaying properly in my Spring application. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tiles are not displaying properly in my Spring application.

    I am new to both Spring and Tiles. I have been working on a very basic application to help me learn both of these technologies, but I have had trouble getting my tiles to show up correctly in my application. The application will call my layout file but it won't insert the tiles the layout requests. Instead, everywhere that I had something like <tiles:insert name="header" /> it will leave the spot blank rather than inserting the tile.

    Here are my definitions:

    <definition name="main_template" page="/WEB-INF/jsp/fh_layout.jsp">
    <put name="header" VALUE="/WEB-INF/jsp/fh_header.jsp" type="page"/>
    <put name="footer" VALUE="/WEB-INF/jsp/footer.jsp" type="page"/>
    <put name="links" VALUE="/WEB-INF/jsp/fh_links_general.jsp" type="page"/>
    </definition>

    <definition name="index" extends="main_template">
    <put name="content" VALUE="/WEB-INF/jsp/fh_norton_origins.jsp" type="page"/>
    </definition>

    <definition name="origins" extends="main_template">
    <put name="content" VALUE="/WEB-INF/jsp/fh_norton_origins.jsp" type="page"/>
    </definition>

    <definition name="tree" extends="main_template">
    <put name="content" VALUE="/WEB-INF/jsp/fh_norton_tree.jsp" type="page"/>
    </definition>


    This is the layout file fh_layout.jsp:

    <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title><tiles:getAsString name="title" ignore="true"/></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="styles/main.css" />
    <link rel="stylesheet" type="text/css" href="styles/interior_layout.css" />

    </head>

    <body>

    <table align="center" width="95%">
    <tr>
    <td>

    <div id="wrapper" >

    <tiles:insert name="header" />

    <div id="main">
    <tiles:insert name="links" />
    <tiles:insert name="content" />

    </div> <!-- End of Main div -->

    <tiles:insert name="footer" />

    </div><!-- END OF WRAPPER DIV -->

    </td>
    </tr>
    </table>


    </body>
    </html>


    And here is my servlet file:

    <!--Map the view name - for instance 'origins' - to the tile in the definition file with the same name. -->
    <bean id="viewResolver" class="org.springframework.web.servlet.view.Intern alResourceViewResolver">
    <property name="requestContextAttribute"><value>requestConte xt</value></property>
    <property name="viewClass">
    <value>org.springframework.web.servlet.view.tiles. TilesJstlView</value>
    </property>
    </bean>


    <!-- Read in the Tiles definitions file that maps the view name to the correct tiles (.jsp files).-->

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

    <!-- This maps the url filename to a view of the same name. For instance, /origins.html is mapped
    to the view 'origins'. -->
    <bean id="viewController" class="org.springframework.web.servlet.mvc.UrlFile nameViewController"/>

    <!-- Send the files listed in the mappings here to the specified controller. -->
    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="mappings">
    <props>
    <prop key="/*.html">viewController</prop>
    </props>
    </property>
    </bean>

    Can anybody tell me where I have gone wrong?

    Thanks

  • #2
    A blank page with Tiles usually means Tiles cannot find the page requested. I can't dig into this any further right now, but maybe this helps you a bit?

    Comment


    • #3
      Thanks for your reply. I figured out what the problem was. I was using Dreamweaver MX to edit my definitions XML file. For some reason, when I saved my file Dreamweaver would change it somehow in ways that weren't always visible - I think it was changing the character encoding. Sometimes after saving it I would notice that some of the XML element attribute names were changed to be all uppercase.

      As soon as I switched to a different text-editor my problem went away.

      Comment

      Working...
      X