我的项目中的Sitemesh无法正常运行

时间:2019-07-30 08:22:17

标签: java html web java-ee

在JSP页面上,“ allStudents”和“ Login”模板有效。但是在页面“ allStudentsAdmin”上它不起作用。我写得不错,但是不起作用,我通过Tomcat在netbeans中运行它。看代码。也许出了点问题。

MySiteMeshFilter。

import org.sitemesh.builder.SiteMeshFilterBuilder;
import org.sitemesh.config.ConfigurableSiteMeshFilter;

public class MySiteMeshFilter extends ConfigurableSiteMeshFilter {

  @Override
  protected void applyCustomConfiguration(SiteMeshFilterBuilder builder) {

            builder.addDecoratorPath("/*", "/WEB-INF/decorators/homeDecorator.jsp") 

           .addDecoratorPath("/allStudents", "/WEB-INF/decorators/homeDecorator.jsp")

           .addDecoratorPath("/login", "/WEB-INF/decorators/loginDecorator.jsp")
           .addDecoratorPath("/allStudentsAdmin", "/WEB-INF/decorators/allStudentsAdminDecorator.jsp");






  }

}

AllStudentsAdminDecorator

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="styleadmin.css" rel="stylesheet" type="text/css" media="screen" />
</head>
<!DOCTYPE html>
<div id="header-wrapper">
    <div id="header">
        <div id="menu">
            <ul>
                <li class="current_page_item"><a href="${pageContext.request.contextPath}/">Главная страница</a></li>
                                <sec:authorize access="hasRole('ADMIN') || hasRole('USER')">
                                <li><a href="${pageContext.request.contextPath}/addStudent">Добавить студента</a></li>
                                </sec:authorize>
                                <sec:authorize access="!isAuthenticated()">
                <li><a href="${pageContext.request.contextPath}/login"></a>Войти</li>
                                </sec:authorize>
                                <sec:authorize access="isAuthenticated()">
                <li><a href="${pageContext.request.contextPath}/logout" class="last">Выйти</a></li>
                                </sec:authorize>
            </ul>
        </div>
        <!-- end #menu -->
        <div id="search">
            <form method="get" action="">
                <fieldset>
                    <input type="text" name="s" id="search-text" size="15" />
                    <input type="submit" id="search-submit" value="GO" />
                </fieldset>
            </form>
        </div>
        <!-- end #search -->
    </div>
</div>
<!-- end #header -->
<!-- end #header-wrapper -->
<div id="logo">
    <h1><a href="#">Predilection </a></h1>
    <p><em> template design by <a href="http://www.freecsstemplates.org/">Free CSS Templates</a></em></p>
</div>





        <sitemesh:write property='body'/>
    <jsp:include page="/WEB-INF/template/allStudentsAdmintemplate.jsp"/>  
    </body>
</html>

AllStudentsAdmin

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
        <title>Home</title>

    </head> 
    <body>

        <div class="add">
            <br>
            <br>
            <br>

            <br>
            <center>
                <h1>${headerMessage}</h1>

                <form:form method="POST" action="${pageContext.request.contextPath}/admin/addStudentAdmin" enctype="multipart/form-data">
                    <table>

                        <tr>
                            <td><label path="Name">Name</label></td>
                            <td><input type="text" name="name"/></td>
                        </tr>

                        <tr>
                            <td><label path="Surname">Surname</label></td>
                            <td><input type="text" name="surname"/></td>
                        </tr>
                        <tr>
                            <td><label path="Avatar">Avatar:</label></td>
                            <td>
                                <input type="file" name="avatar"/>
                            </td>

                        </tr>

0 个答案:

没有答案