Announcement Announcement Module
Collapse
No announcement yet.
Problems using JSTL with Tiles 2 integrations in Spring MVC 2.5 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems using JSTL with Tiles 2 integrations in Spring MVC 2.5

    I've been trying to get this simple page utilizing TIles 2 and JSTL as my view in MVC 2.5. I can't seem to find any decent results with a google search, so i'm hoping some one here can tell me what i'm doing wrong. I'll include all my code beneath. I've tried JSTL 1.1.2 and 1.2, as well as Tiles 2.0.6 and 2.1, but still no dice. I've tried running it on tomcat 6, and jboss 4.0. When i debug in intellij i can find the value there in the request, it's a couple of layers deep, but still there, so i can only assume that it's ome sort of resolution problem. any who, here's the relevant bits of code.

    Here are my dependencies from pom.xml
    Code:
    	<dependencies>
    		<dependency>
    			<groupId>junit</groupId>
    			<artifactId>junit</artifactId>
    			<version>4.5</version>
    			<scope>test</scope>
    		</dependency>
    		<dependency>
    			<groupId>javax.servlet</groupId>
    			<artifactId>servlet-api</artifactId>
    			<version>2.5</version>
    			<scope>provided</scope>
    		</dependency>
    		<dependency>
    			<groupId>javax.servlet.jsp</groupId>
    			<artifactId>jsp-api</artifactId>
    			<version>2.1</version>
    			<scope>provided</scope>
    		</dependency>
    		<dependency>
    			<groupId>javax.servlet</groupId>
    			<artifactId>jstl</artifactId>
    			<version>1.2</version>
    			<scope>runtime</scope>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring</artifactId>
    			<version>2.5.6</version>
    		</dependency>
    		<dependency>
    			<groupId>org.springframework</groupId>
    			<artifactId>spring-webmvc</artifactId>
    			<version>2.5.6</version>
    		</dependency>
    		<dependency>
    			<groupId>org.apache.tiles</groupId>
    			<artifactId>tiles-core</artifactId>
    			<version>2.0.6</version>
    		</dependency>
    		<dependency>
    			<groupId>org.apache.tiles</groupId>
    			<artifactId>tiles-jsp</artifactId>
    			<version>2.0.6</version>
    		</dependency>
    	</dependencies>
    My website-servlet.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"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
               http://www.springframework.org/schema/context
               http://www.springframework.org/schema/context/spring-context-2.5.xsd">
    
        <context:component-scan base-package="com.ursusdevelopment.website"/>
    
        <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
        </bean>
    
        <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
            <property name="definitions">
                <list>
                    <value>/WEB-INF/tiles-def.xml</value>
                </list>
            </property>
        </bean>
    </beans>
    My tiles-def.xml
    Code:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!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="template" template="/WEB-INF/templates/layout.jsp">
            <put-attribute name="header" value="/WEB-INF/templates/header.jsp"/>
            <put-attribute name="menu" value="/WEB-INF/templates/menu.jsp"/>
            <put-attribute name="footer" value="/WEB-INF/templates/footer.jsp"/>
        </definition>
    
        <definition name="index" extends="template">
            <put-attribute name="title" value="Ursus Software Development, LLC"/>
            <put-attribute name="content" value="/WEB-INF/jsp/index.jsp"/>
        </definition>
    </tiles-definitions>
    layout.jsp
    Code:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
    <html>
    
    	<head>
    		<title><tiles:getAsString name="title"/></title>
    		<link rel="stylesheet" href="styles/ursus.css" type="text/css"/>
    	</head>
    
    	<body>
    		<div class="top"/>
    		<div class="bottom"/>
    		<div class="body">
    			<div class="header"><tiles:insertAttribute name="header"/></div>
    			<div class="menu"><tiles:insertAttribute name="menu"/></div>
    			<div class="content"><tiles:insertAttribute name="content"/></div>
    		</div>
    		<div class="footer"><tiles:insertAttribute name="footer"/></div>
    	</body>
    </html>
    index.jsp
    Code:
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <h3>Hooray for content.</h3>
    <c:out value="${result}"/>
    ${result}
    and MainController.java
    Code:
    @Controller
    public class MainController {
    	/*--------Members--------*/
    
    
    	/*--------Methods--------*/
    
    	/**
    	 * Handles a request for the main page.
    	 */
    	@RequestMapping("/index")
    	public Model viewIndex() {
    		Model model = new ExtendedModelMap();
    		model.addAttribute("result", true);
    		return model;
    		//todo: do any processing neccesary
    	}
    }
    any help would be greatly appreciated. thanks.

  • #2
    I figured out the issue finally. It's because my web xml was using an old 2.3 dtd. When i converted to the 2.5 schema it worked like a champ.

    Comment

    Working...
    X