Foros del Web » Programación para mayores de 30 ;) » Java »

spring tiles no se ve

Estas en el tema de spring tiles no se ve en el foro de Java en Foros del Web. Hola wenas soy nuevo en spring y estoy tratando de usar Tiles 2.2 con Spring MVC 3.0, ya configure los xml necesarios pero no carga ...
  #1 (permalink)  
Antiguo 14/12/2012, 13:44
 
Fecha de Ingreso: mayo-2010
Mensajes: 99
Antigüedad: 13 años, 11 meses
Puntos: 5
spring tiles no se ve

Hola wenas soy nuevo en spring y estoy tratando de usar Tiles 2.2 con Spring MVC 3.0, ya configure los xml necesarios pero no carga la pagina como debe con las divisiones echas en el tiles, lo estoy ejecutando en tomcat-5.5.35 copiando los jar en la carpeta common/lib

este es mi codigo:
web.xml
Código:
<?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
Código:
<?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
Código:
<?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
Código:
<%@ 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
Código:
<%@ 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
Código:
<%@ 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
Código:
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
Código:
<p> Pruebas </p>
header.jsp
Código:
<h1>Header</h1>
menu.jsp
Código:
<p>Menu</p>
  #2 (permalink)  
Antiguo 14/12/2012, 13:45
 
Fecha de Ingreso: mayo-2010
Mensajes: 99
Antigüedad: 13 años, 11 meses
Puntos: 5
Respuesta: spring tiles no se ve

En el log del tomcat solo me carga esto:

- The APR based Apache Tomcat Native library which allows optimal performance in production C:\Archivos de programa\Java\jdk1.5.0_06\bin;;C:\Archivos de programa\JavaFX\javafx-sdk1.1\emulator\bin;C:\WINDOWS\system32;C:\WINDOWS ;C:\WINDOWS\System32\Wbem;C:\Archivos de programa\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\apache-tomcat-5.5.35\common\lib\
- Inicializando Coyote HTTP/1.1 en puerto http-8090
- Initialization processed in 1186 ms
- Arrancando servicio Catalina
- Starting Servlet Engine: Apache Tomcat/5.5.35
- Desactivada la validación XML
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/C:/apache-tomcat-5.5.35/common/lib/slf4j-jdk14-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/apache-tomcat-5.5.35/common/lib/slf4j-log4j12-1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Documents%20and%20Settings/RD89134/Escritorio/Proyecto/ccMexSpring/.deployables/ccMexSpring/WEB-INF/lib/slf4j-jdk14-1.5.8.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/C:/Documents%20and%20Settings/RD89134/Escritorio/Proyecto/ccMexSpring/.deployables/ccMexSpring/WEB-INF/lib/slf4j-log4j12-1.5.6.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
14/12/2012 04:46:16 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring FrameworkServlet 'Spring MVC Dispatcher Servlet'
14/12/2012 04:46:16 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'Spring MVC Dispatcher Servlet': initialization started
14/12/2012 04:46:16 PM org.springframework.context.support.AbstractApplic ationContext prepareRefresh
INFO: Refreshing WebApplicationContext for namespace 'Spring MVC Dispatcher Servlet-servlet': startup date [Fri Dec 14 16:46:16 GMT 2012]; root of context hierarchy
14/12/2012 04:46:16 PM org.springframework.beans.factory.xml.XmlBeanDefin itionReader loadBeanDefinitions
INFO: Loading XML bean definitions from ServletContext resource [/WEB-INF/springmvc-config.xml]
14/12/2012 04:46:18 PM org.springframework.beans.factory.support.DefaultL istableBeanFactory preInstantiateSingletons
INFO: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultL istableBeanFactory@1c18a4c: defining beans [homeControlador,org.springframework.context.annota tion.internalConfigurationAnnotationProcessor,org. springframework.context.annotation.internalAutowir edAnnotationProcessor,org.springframework.context. annotation.internalRequiredAnnotationProcessor,vie wResolver,tilesConfigurer,viewResolver1]; root of factory hierarchy
14/12/2012 04:46:18 PM org.springframework.web.servlet.view.tiles2.TilesC onfigurer setDefinitions
INFO: TilesConfigurer: adding definitions [/WEB-INF/views.xml]
14/12/2012 04:46:18 PM org.apache.tiles.context.AbstractTilesApplicationC ontextFactory createFactory
INFO: Initializing Tiles2 application context. . .
14/12/2012 04:46:18 PM org.apache.tiles.context.AbstractTilesApplicationC ontextFactory createFactory
INFO: Finished initializing Tiles2 application context.
14/12/2012 04:46:18 PM org.apache.tiles.access.TilesAccess setContainer
INFO: Publishing TilesContext for context: org.springframework.web.servlet.view.tiles2.Spring TilesApplicationContextFactory$SpringWildcardServl etTilesApplicationContext
14/12/2012 04:46:19 PM org.springframework.web.servlet.handler.AbstractUr lHandlerMapping registerHandler
INFO: Mapped URL path [/home] onto handler [com.controlador.HomeControlador@135f44e]
14/12/2012 04:46:19 PM org.springframework.web.servlet.handler.AbstractUr lHandlerMapping registerHandler
INFO: Mapped URL path [/home.*] onto handler [com.controlador.HomeControlador@135f44e]
14/12/2012 04:46:19 PM org.springframework.web.servlet.handler.AbstractUr lHandlerMapping registerHandler
INFO: Mapped URL path [/home/] onto handler [com.controlador.HomeControlador@135f44e]
14/12/2012 04:46:19 PM org.springframework.web.servlet.FrameworkServlet initServletBean
INFO: FrameworkServlet 'Spring MVC Dispatcher Servlet': initialization completed in 3326 ms
- Arrancando Coyote HTTP/1.1 en puerto http-8090
- JK: ajp13 listening on /0.0.0.0:8019
- Jk running ID=0 time=0/63 config=null
- Find registry server-registry.xml at classpath resource
- Server startup in 5371 ms
14/12/2012 04:46:20 PM com.controlador.HomeControlador showHome
INFO: in home...

Y la pagina que me muestra es la de Home.jsp pero sin los tiles
Que podria estar haciendo mal, les agradezco me orientaran

Etiquetas: jar, jsp, spring, tildes
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:36.