Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/344.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
Java Spring Boot Thymeleaf:如何包含html文件_Java_Html_Spring_Spring Boot_Thymeleaf - Fatal编程技术网

Java Spring Boot Thymeleaf:如何包含html文件

Java Spring Boot Thymeleaf:如何包含html文件,java,html,spring,spring-boot,thymeleaf,Java,Html,Spring,Spring Boot,Thymeleaf,我的弹簧靴有问题。我想在另一个带有Thymeleaf的html文件中包含一个简单的html文件 这里是我的main.html文件: 在CODESPENPET的中间,您可以看到根div,这里我要包含dasBead .HTML文件。 <!DOCTYPE HTML> <html xmlns:th="http://www.thymeleaf.org"> <head> <title>Admin-Area</title> <m

我的弹簧靴有问题。我想在另一个带有Thymeleaf的html文件中包含一个简单的html文件

这里是我的main.html文件: 在CODESPENPET的中间,您可以看到根div,这里我要包含dasBead .HTML文件。

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>Admin-Area</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="/backend/webjars/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="/backend/webjars/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
    <nav class="navbar navbar-dark sticky-top bg-dark flex-md-nowrap p-0 fixed-top mainnav navbar-expand-xl">
        <a class="navbar-brand col-sm-3 col-md-2 mr-0" href="../dashboard/dashboard.html">B2C-Shop</a>
        <button type="button" class="navbar-toggler navbar-toggler-right">
            <span class="navbar-toggler-icon"></span>
        </button>
    </nav>
    <div class="container-fluid">
        <div class="row">
            <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
                <div th:each="script: ${scripts}">
                    <div th:if="${script.endsWith('dashboard.html')}">
                        <div id="root" th:include="dashboard :: dashboard></div>
                    </div>
                </div>
            </main>
        </div>
    </div>

    <script src="/backend/webjars/es5-shim/4.5.9/es5-shim.min.js"></script>
    <script src="/backend/webjars/es6-shim/0.20.2/es6-shim.min.js"></script>
    <script src="/backend/webjars/jquery/3.3.1/jquery.min.js"></script>
    <script src="/backend/webjars/bootstrap/4.0.0/js/bootstrap.min.js"></script>
    <script src="/backend/webjars/modernizr/2.8.3/modernizr.min.js"></script>
    <div th:each="script: ${scripts}">
        <div th:if="${script.endsWith('.js')}">
            <script type="text/javascript" th:src="'/backend/js' + ${script}"></script>
        </div>
    </div>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <div th:fragment="dashboard">
        <h1>Welcome to B2C-Admin-Area</h1>
    </div>
</html>
我的文件夹结构如下所示:

你有没有办法把这个文件包括进去

多谢各位


关于MWC。

首先按照以下结构排列html文件:

然后创建要导入的片段,如下所示: 假设您将以下代码保存在template/common文件夹中的面包屑文件中:

<section class="content-header" th:fragment="breadcrumbfragment">
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li class="active">Next </li>
        <li class="active">Next to Next</li>
    </ol>
</section>

  • 下一步
  • 下一个
  • 现在要导入上述片段,请使用以下行:

    <section class="content-header" th:replace="common/breadcrumb::breadcrumbfragment"></section>
    

    谢谢,如果您将文件夹结构更改为/templates/dashboard/dashboard.html,而不是它的工作方式。
    <section class="content-header" th:replace="common/breadcrumb::breadcrumbfragment"></section>