Thymeleaf之HTML分模块

 common_css导入css样式:

<html xmlns:th="http://www.thymeleaf.org">
<!--公共css-->
<th:block th:fragment="common_css">
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="stylesheet" href="/backstage/plugins/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/backstage/plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/backstage/plugins/ionicons/css/ionicons.min.css">
    <link rel="stylesheet" href="/backstage/plugins/iCheck/square/blue.css">
    <link rel="stylesheet" href="/backstage/plugins/morris/morris.css">
    <link rel="stylesheet" href="/backstage/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
</th:block>
<!--公共CSS-->

  common_css导入js样式:

<html xmlns:th="http://www.thymeleaf.org">
<!--公共JS-->
<th:block th:fragment="common_js">
    <script src="/backstage/plugins/jQuery/jquery-2.2.3.min.js"></script>
    <script src="/backstage/plugins/jQueryUI/jquery-ui.min.js"></script>
    <script>
        $.widget.bridge('uibutton', $.ui.button);
    </script>
    <script src="/backstage/plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="/backstage/plugins/raphael/raphael-min.js"></script>
    <script src="/backstage/plugins/morris/morris.min.js"></script>
    <script src="/backstage/plugins/sparkline/jquery.sparkline.min.js"></script>
    <script src="/backstage/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
    <script src="/backstage/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
</th:block>
<!--公共JS-->

 common_header侧边栏:

<html xmlns:th="http://www.thymeleaf.org">
<!-- 页面头部 -->
<header class="main-header" th:fragment="header">
    <!-- Logo -->
    <a href="/backstage/index" class="logo">
        <span class="logo-mini"><b>后台</b></span>
        <span class="logo-lg">数据<b>后台</b>管理</span>
    </a>
    <!--导航右边头像-->
    <nav class="navbar navbar-static-top">
    </nav>
    <!--导航右边头像-->
</header>
<!-- 页面头部 -->

 common_aside侧边栏:

<html xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">

<!--导航侧栏-->
<aside class="main-sidebar" th:fragment="aside">
    <!--侧边栏-->
        <section class="sidebar">
            <!-- 侧边栏内容 -->
        </section>
    <!--侧边栏-->
    <script>
        $(function () {
            // 点击外层菜单时记录他的id
            $(".treeview").click(function () {
                sessionStorage.menu = $(this).attr("id");
            })
            // 点击内层菜单时记录他的id
            $(".treeview-menu li").click(function () {
                sessionStorage.menu2 = $(this).attr("id");
            })

            // 对已点击的外层菜单添加class属性为active
            $("#"+sessionStorage.menu).addClass("active");
            // 对已点击的内层菜单添加颜色样式
            $("#"+sessionStorage.menu2+" a").css("color","white");
        });
    </script>
</aside>
<!--导航侧栏-->

 common_footer侧边栏:

<html xmlns:th="http://www.thymeleaf.org">

<!-- 底部导航 -->
<footer class="main-footer" th:fragment="footer">
    <div class="pull-right hidden-xs">
        <b>Version</b> 1.0.8
    </div>
    <strong>Copyright &copy; <a href="https://blog.csdn.net/qq_46372272">Orion猎户博客</a>.</strong>All rights reserved.
</footer>
<!-- 底部导航 -->

 总结: 将公用的模块进行组合 

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>新增产品类型</title>
    <th:block th:replace="/backstage/common/common_resources::common_css"/>
    <th:block th:replace="/backstage/common_resources::common_js"/>
</head>
<body class="hold-transition skin-purple sidebar-mini">
<div class="wrapper">
    <!-- 页面头部 -->
    <header th:replace="/backstage/common/common_header::header"></header>
    <!-- 导航侧栏 -->
    <aside th:replace="/backstage/common/common_aside::aside"></aside>
    <!-- 内容区域 -->
    <div class="content-wrapper">
    </div>
    <!-- 底部导航 -->
    <footer th:replace="/backstage/common/common_footer::footer"></footer>
</div>
</body>
</html>

 

 孤独&烙印的博客_CSDN博客-nginx,Shiro,springSecurity领域博主

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

孤独&烙印

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值