我不知道是什么问题,我没有语法错误,但我应该有一个导航栏在我的屏幕顶部,但它没有显示出来。语法中有什么需要修改的吗?我是否也在默认模板文件中遗漏了什么?我的网页显示良好,但我只是缺少我的图像和导航栏。
common.html文件
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<div th:fragment="header">
<h1>Welcome to my CST-339 Spring Boot Activity Application</h1>
</div>
<div class="bs-example">
<nav class="navbar navbar-default">
<div class="navbar-header">
<button type="button" data-target="navbarCollapse" data-toggle="collapse" class="navbar-toggle">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="#" class="navbar-brand">GCU</a>
</div>
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a href="https://www.gcu.edu" target="_blank">Home</a>
</li>
<li>
<a href="https://www.lopeshops.edu" target="_blank">Shop</a>
</li>
<li>
<a href="https://www.news.edu" target="_blank">News and Events</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="/">Start Page</a></li>
</ul>
</div>
</nav>
</div>
<h2 th:text="${title}">Default Message Text</h2><br />
<img th:src="@{/static/images/gcu-logo.jpg}" /><br /><br />
<div th:fragment="footer">
<h5 style="color:purple; text-align: center; position: fixed; bottom: 0; width: 100%;">Copyright 2020 Grand Canyon University</h5>
</div>
</html>
字符串
defaultTemplate.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title> CST-339 Spring Boot Activity Application</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css.bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css.bootstrap-theme.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
<link rel="stylesheet" href="https://cdn.datatables.net/responsive/2.2.0/css/responsive.dataTables.css">
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="//cdn.datatables.net/responsive/2.2.0/js/dataTables.responsive.js"></script>
<style type="text/css">.bs-example {margin: 20px; }</style>
</head>
<body>
<div align="center">
<div th:replace="~{layouts/common :: header}">My Header</div>
<section layout:fragment="content">
<p>My Body Contents</p>
</section>
<div th:replace="~{layouts/common :: footer}">My Footer</div>
</div>
</body>
</html>
型
2条答案
按热度按时间t0ybt7op1#
假设您的徽标位于static/images文件夹中,显示它
更换
字符串
与
型
klr1opcd2#
如果是导航栏
第一css链接不可访问而不是
字符串
应该是
型
第二:当设置样式
class
时,您缺少th
,即对于单个类,应为th:class="class-name"
,对于多个类,应为th:classappend="|class1 class2 class3|"
第三:要使导航按钮在菜单折叠时显示菜单,
data-target
值应该是.navbar-collapse
而不是navbarCollapse
下面的完整示例加载可折叠的导航栏
型