2013-01-07 45 views
1

我想包括sitemesh到我的spring-mvc web應用程序。 我將此添加到我的web.xml:sitemesh和spring:只有index.jsp被裝飾

<filter> 
<filter-name>sitemesh</filter-name> 
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class> 
</filter> 

<filter-mapping> 
<filter-name>sitemesh</filter-name> 
<url-pattern>/*</url-pattern> 
</filter-mapping> 

我decorators.xml文件:

<decorators defaultdir="/WEB-INF/decorators"> 
    <decorator name="master" page="master.jsp"> 
     <pattern>/</pattern> 
    </decorator> 
</decorators> 

而且master.jsp文件:

<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator" %> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
    <title> 
     :: LiVis :: <decorator:title /> :: 
    </title> 
    <style type="text/css">@import "resources/css/generalStyle.css";</style> 
    </head> 
    <body> 
     <div id="wrapper"> 
      <div id="header"> 
       <div id="headerPicture"> 
        <img id="livis" src="resources/images/village.png" alt="livis" /> 
       </div> 
       <div id="headerMenu"> 
        <ul id="navigation"> 
         <li><a href="admin/insertEntryForm.html">Insert</a></li> 
         <li>Table-View</li> 
         <li>Graph-View</li> 
         <li>About</li> 
        </ul> 
       </div> 
      </div> 
      <div id="main"> 
       <decorator:body /> 
      </div> 
     </div> 
    </body> 
</html> 

我thougt,即master.jsp將應用於我的webapp中的每個頁面,但只能使用index.jsp完成。 要其他jsp文件,這些文件位於WEB-INF/views中的某些文件夾中(請參見圖片),但尚未完成。 folder-structure in WEB-INF

這可能是什麼原因? 謝謝!

編輯

一個頁面在vwies /管理文件夾:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<%@ 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"%> 
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<html> 
<head> 
<title>Registration Page</title> 
</head> 
<body> 

<form:form method="POST" action="/LiteratureVisualization/admin/insertTest" modelAttribute="object"> 
    <table> 
     <tr> 
      <td>First name:</td> 
      <td><form:input path="author.firstname" /></td> 
     </tr> 
     <tr> 
      <td>Last name:</td> 
      <td><form:input path="author.lastname" /></td> 
     </tr> 
     <tr> 
      <td>Title:</td> 
      <td><form:input path="publication.title" /></td> 
     </tr> 
     <tr> 
      <td>Subtitle:</td> 
      <td><form:input path="publication.subtitle" /></td> 
     </tr> 
     <tr> 
      <td>Abstract:</td> 
      <td><form:input path="publication.abstr" /></td> 
     </tr> 
     <tr> 
      <td>Year of Launch:</td> 
      <td><form:input path="publication.launchYear" /></td> 
     </tr> 
     <tr> 
      <td>Month of Launch:</td> 
      <td><form:input path="publication.launchMonth" /></td> 
     </tr> 
     <tr> 
      <td>Volume:</td> 
      <td><form:input path="publication.volume" /></td> 
     </tr> 
     <tr> 
      <td>Number:</td> 
      <td><form:input path="publication.number" /></td> 
     </tr> 
     <tr> 
      <td>Sort of:</td> 
      <td><form:input path="publication.sortOf" /></td> 
     </tr> 
     <tr> 
      <td>Published In:</td> 
      <td><form:input path="publication.publishedIn" /></td> 
     </tr> 
     <tr> 
      <td colspan="2"><input type="submit" value="Register"></td> 
     </tr> 
    </table> 
</form:form> 
</body> 
</html> 

回答

0

使用/ *代替/在你的模式聲明。

或者如果它不能解決問題,請查看您的jsp文件並檢查是否有html和body標籤。如果沒有,sitemesh不能替換裝飾器中聲明的標籤。

+0

這沒有奏效...是否有可能,在管理員,瀏覽器,一般和圖文件夾的jsp的無法找到? – bethlis

+0

你能編輯你的文章並向我們展示一個頁面到這個文件夾中嗎?您是否嘗試添加如下模式:/ views/admin/*來測試這是一個路徑問題還是一個jsp問題? –