Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 如何在一个特定页面上用自定义页脚替换版面中的页脚_Css_Html_Spring Mvc_Thymeleaf - Fatal编程技术网

Css 如何在一个特定页面上用自定义页脚替换版面中的页脚

Css 如何在一个特定页面上用自定义页脚替换版面中的页脚,css,html,spring-mvc,thymeleaf,Css,Html,Spring Mvc,Thymeleaf,我的问题是-我有两个文件: layout.html: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" th:fragment="layout"> <head> <title >Layout page</title> </head> <body> <header

我的问题是-我有两个文件: layout.html:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
th:fragment="layout">
<head>
<title >Layout page</title>    
</head>
<body>
<header>
  <h1>My website</h1>
</header>
<section th:include="this :: content">
  <p>Page content goes here</p>
</section>
<footer th:fragment="footer" >
  <p>My footer</p>      
</footer>  
</body>
</html>

版面页
我的网站
页面内容在这里

我的页脚

和index.html:

<!DOCTYPE html >
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
th:include="layout :: layout">
<head>
<title>Index page</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
 <h2>Hello World!</h2>

<section class="seedstarterlist" th:fragment="content" >
    <form action="#" th:action="@{/add}" th:object="${user}" method="post">
        <table>
            <tbody>
                <tr>
                    <td>name</td>
                    <td><input type="text" th:field="*{name}"  /></td>
                </tr>
                <tr>
                    <td>surname</td>
                    <td><input type="text" th:field="*{surname}"  /></td>
                </tr>
                <tr>
                    <td>email</td>
                    <td><input type="text" th:field="*{email}"  /></td>
                </tr>
                <tr>
                    <td>street</td>
                    <td><input type="text" th:field="*{street}"  /></td>
                </tr>
                <tr>
                    <td>postcode</td>
                    <td><input type="text" th:field="*{postcode}"  /></td>
                </tr>
                <tr>
                    <td>city</td>
                    <td><input type="text" th:field="*{city}"  /></td>
                </tr>
                <tr>
                    <td>district</td>
                    <td><input type="text" th:field="*{district}"  /></td>
                </tr>
                <tr>
                    <td>country</td>
                    <td><input type="text" th:field="*{country}"  /></td>
                </tr>
                <tr>
                    <td>nationality</td>
                    <td><input type="text" th:field="*{nationality}"  /></td>
                </tr>
                <tr>
                    <td>phoneNumber</td>
                    <td><input type="text" th:field="*{phoneNumber}"  /></td>
                </tr>
                <tr>
                    <td>avatar</td>
                    <td><input type="text" th:field="*{avatar}"  /></td>
                </tr>
                <tr>
                    <td>password</td>
                    <td><input type="text" th:field="*{password}"  /></td>
                </tr>
                <tr>
                    <td>status</td>
                    <td><input type="text" th:field="*{status}"  /></td>
                </tr>
                <tr>
                    <td>sex</td>
                    <td><input type="text" th:field="*{sex}"  /></td>
                </tr>
                <tr>
                    <td>birthdate</td>
                    <td><input type="text" th:field="*{birthdate}"  /></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <button type="submit" name="add">Add User</button>
                    </td>
                </tr>
            </tbody>
        </table>
    </form>
</section>
<footer th:fragment="footer" >
  <p>My custom footer</p>      
</footer>

索引页
你好,世界!
名称
姓
电子邮件
街道
邮政编码
城市
区
国家
国籍
电话号码
阿凡达
密码
地位
性
生日
添加用户
我的自定义页脚

我只希望在index.html页面上有自定义页脚。布局工作正常,但我想覆盖这个特定页面上的页脚,但这不起作用


有什么帮助吗?

答案是我需要改变我的方法并使用ThymeLeaf布局方言。我在Spring配置文件中注册了其他模板引擎:

<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
  <property name="additionalDialects">
    <set>
      <bean class="nz.net.ultraq.thymeleaf.LayoutDialect"/>
    </set>
  </property>
</bean>

并将html顶部的声明更改为:

<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
  layout:decorator="layout.html">


希望它能帮助一些人。

看看这个问题:好的,我改变了我的方法,使用了ThymeLeaf布局方言,布局:fragment tag:)Thx很多:)