我正在使用瓷磚一個Spring MVC的項目。當我運行的應用程序,我沒有得到任何error.But jsp頁面加載不正確像下面Spring MVC的瓷磚jsp頁面中正確載入
當我看到此頁面的源代碼時,我可以看到layout.jsp和home.jsp代碼已加載。但是,如上所示,頁面僅顯示jsp標記。
開發環境
-> Spring MVC 3.2.8 Release
-> Apache Tiles 2.2.1
tiles-core-2.2.1.jar
tiles-template-2.2.1.jar
tiles-jsp-2.2.1.jar
tiles-servlet-2.2.1.jar
tiles-api-2.2.1.jar
tiles-request-api-1.0.1.jar
的pom.xml
<!-- Servlet -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
的web.xml
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
tiles.xml
<?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.definition"
template="/WEB-INF/views/templates/template1/layout.jsp">
<put-attribute name="title" value=""/>
<put-attribute name="header" value="/WEB-INF/views/templates/components/header.jsp"/>
<put-attribute name="menu" value="menu"/>
<put-attribute name="body" value=""/>
<put-attribute name="footer" value="/WEB-INF/views/templates/components/footer.jsp"/>
</definition>
<definition name="menu"
preparer="menuController"
template="/WEB-INF/views/templates/components/menu.jsp">
</definition>
<definition name="home" extends="base.definition">
<put-attribute name="title" value="Home"/>
<put-attribute name="body" value="/WEB-INF/views/home.jsp"/>
</definition>
layout.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ 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><tiles:getAsString name="title"/></title>
<link rel="stylesheet" type="text/css" href="<c:url
value='/resources/css/style.css'/>"/>
</head>
<body>
<div id="layout">
<div id="header">
<tiles:insertAttribute name="header" />
</div>
<div id="content">
<div id="leftContent">
<tiles:insertAttribute name="menu" />
</div>
<div id="rightContent">
<tiles:insertAttribute name="body" />
</div>
</div>
<div id="footer">
<tiles:insertAttribute name="footer" />
</div>
</div>
</body>
</html>
針對home.jsp
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<c:if test="${!empty kodListe}">
<h3 >En Son Eklenenler</h3>
<c:forEach items="${kodListe}" var="kod">
<form:form action="kod" method="POST">
<table>
<tr>
<td>
<input type="hidden" name="kodId" value="${kod.kodId}" />
<input value="${kod.kodBaslik}" type="submit"/>
</td>
</tr>
<tr>
<td>
${kod.kodEkleyenKullanici.kullaniciAd}
</td>
<td>
${kod.kodEklemeTarihi}
</td>
</tr>
</table>
</form:form>
</c:forEach>
servlet的context.xml中
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.tiles2.TilesView">
</property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
如何解決這個問題呢?在此先感謝