Announcement Announcement Module
Collapse
No announcement yet.
I cant see the tiles when run my webproject Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • I cant see the tiles when run my webproject

    Hi everything, I am newbie in Spring MVC 3.0, I am trying use tiles 2.2.2 , my app is on Tomcat 5.5, this is my code, sorry for my poor english :

    web.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
    <display-name>ccMexSpring</display-name>
    <servlet>
            <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
            <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
            <init-param>
                <param-name>contextConfigLocation</param-name>
                <param-value>
                    /WEB-INF/springmvc-config.xml
                </param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
        </servlet>
         <servlet-mapping>
      <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
         <url-pattern>*.htm</url-pattern>
       </servlet-mapping>
        <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
    springmvc-config.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
        <context:component-scan base-package="com.controlador" />
    <bean id="viewResolver" 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>
            <property name="suffix" value=".jsp"></property>        
        </bean>       
        <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
    <list>
    <value>/WEB-INF/views.xml</value>
    </list>
    </property>
    </bean>
       
        <bean id="viewResolver1" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
    </bean>
    </beans>
    views.xml
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE tiles-definitions PUBLIC
           "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
           "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
    <tiles-definitions>
        <definition name="base" template="/WEB-INF/jsp/plantilla.jsp">
            <put-attribute name="title" value="titulo" />
            <put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
            <put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />
            <put-attribute name="body" value="" />
            <put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
        </definition>
        <definition name="home" extends="base">
            <put-attribute name="title" value="Contact Manager" />
            <put-attribute name="body" value="/WEB-INF/jsp/home.jsp" />
        </definition>
    </tiles-definitions>
    plantilla.jsp
    Code:
    <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title><tiles:insertAttribute name="title" ignore="true" /></title>
    </head>
    <body>
    <table border="1" cellpadding="2" cellspacing="2" align="center">
        <tr>
            <td height="30" colspan="2"><tiles:insertAttribute name="header" />
            </td>
        </tr>
        <tr>
            <td height="250"><tiles:insertAttribute name="menu" /></td>
            <td width="350"><tiles:insertAttribute name="body" /></td>
        </tr>
        <tr>
            <td height="30" colspan="2"><tiles:insertAttribute name="footer" />
            </td>
        </tr>
    </table>
    </body>
    </html>
    index.jsp
    Code:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Spring 3 MVC Tile Plug-in</title>
    </head>
    <body>
    <jsp:forward page="home.htm"></jsp:forward>
    </body>
    </html>
    home.jsp
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Home App Spring</title>
    </head>
    <body>
    <h1>Hello - Spring Application</h1>
    </body>
    </html>

    HomeControlador.java
    Code:
    package com.controlador;
     
    import java.io.IOException;
    import java.util.Map;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    import org.springframework.stereotype.Controller;
    import org.springframework.ui.Model;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.servlet.ModelAndView;
      
    @Controller
    public class HomeControlador {
     
    protected final Log logger = LogFactory.getLog(getClass());
     
    @RequestMapping("/home")
    public ModelAndView showHome()
    {
    logger.info("in home...");
    return new ModelAndView("home");
    }
    }
    footer.jsp
    Code:
    <p> Pruebas </p>
    header.jsp
    Code:
    <h1>Header</h1>
    menu.jsp
    Code:
    <p>Menu</p>

  • #2
    I'm experiencing a problem identical to its. Did you find some way to fix this issue ?

    Comment


    • #3
      Originally posted by jamesfrj View Post
      I'm experiencing a problem identical to its. Did you find some way to fix this issue ?
      Hi friend, I resolved this issue just I downloaded an example from this page and run it

      http://www.dzone.com/tutorials/java/...gration-1.html

      I hope this help

      Cheers

      Comment


      • #4
        Thanks

        Originally posted by peterfes View Post
        Hi friend, I resolved this issue just I downloaded an example from this page and run it

        http://www.dzone.com/tutorials/java/...gration-1.html

        I hope this help

        Cheers
        Thank you, my friend.

        Comment

        Working...
        X