【问题标题】:sitemesh and spring: only index.jsp is decoratedsitemesh 和 spring:只有 index.jsp 被修饰
【发布时间】:2012-12-21 01:10:01
【问题描述】:

我正在尝试将 sitemesh 包含到我的 spring-mvc 网络应用程序中。 我将此添加到我的 web.xml 中:

<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>

我认为 master.jsp 将应用于我的 webapp 中的每个页面,但它仅适用于 index.jsp。 对于其他 jsp 文件,它们位于 WEB-INF/views 的某些文件夹中(见图),它没有完成。

这可能是什么原因? 谢谢!!

编辑

vwies/admin 文件夹中的一个页面:

<%@ 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>

【问题讨论】:

    标签: spring spring-mvc sitemesh


    【解决方案1】:

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

    或者如果它不能解决问题,请查看您的 jsp 文件并检查其中是否包含 html 和 body 标签。如果不是,sitemesh 不能用装饰器中声明的标签替换标签。

    【讨论】:

    • 这不起作用...是否有可能,在 tha admin、browse、general 和 graph-folder 中找不到 jsp?
    • 您可以编辑您的帖子并向我们展示此文件夹中的页面吗?您是否尝试添加类似:/views/admin/* 的模式来测试这是路径问题还是 jsp 问题?
    猜你喜欢
    • 2011-02-20
    • 2013-08-25
    • 2011-05-21
    • 2013-11-15
    • 2013-08-02
    • 2016-10-07
    • 2017-09-21
    • 2017-12-22
    • 2017-05-08
    相关资源
    最近更新 更多