mardi 30 juillet 2019

Sitemesh in my project does not work correctly

On the JSP pages "allStudents" and "Login" template works. But on the page "allStudentsAdmin" it does not work. I sort of wrote it right, but it doesn't work.I run it through netbeans through Tomcat. Look at the code. Maybe something is wrong.

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>




Aucun commentaire:

Enregistrer un commentaire