Meu include com o Thymeleaf
não carrega. Alguém pode me ajudar ?
Meu layout padrão É:
<!DOCTYPE html>
<html xmlns= *"http://www.w3.org/1999/xhtml"*
xmlns:th= *"http://www.thymeleaf.org"*
xmlns:layout= *"http://www.ultraq.net.nz/thymeleaf/layout"* >
**Definido =>** <header layout:include= *"Cabecalho"* ></header
**Definido =>** <section layout:fragment= *"conteudo"* >
<p>Conteúdo principal</p>
</section>
Criei a página certinho e o pom.xml está tudo ok.
Além disso defini o layout:decorator= “LayoutPadrao” da página de cadastro e a seção <section layout:fragment= “conteudo”> para carregar o conteúdo no LayoutPadrão…
Funcionou com o layout:fragment= “conteudo”> porem o include ainda não.
1 curtida
Tenta usar: layout:insert=“Cabecalho”
Funcionou pra mim aqui! Obrigado, Alex!
Agora me veio uma dúvida.
No material que acompanho utilizou-se o “include” e funcionou, mas no meu caso pode ter sido devido a versão do thymeleaf, não é?
thimor
Junho 9, 2020, 6:20pm
#7
o thymeleaf saiu mudando varias tags ao longo da evolucao de suas versoes, eu nunca usei o include, eu uso mais o fragmet e o replace
<!DOCTYPE html>
<html lang="pt" xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="stylesheet" type="text/css" th:href="@{/layout/plugins/fontawesome-free/css/all.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/layout/plugins/overlayScrollbars/css/OverlayScrollbars.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/layout/plugins/select2/css/select2.min.css}">
<link rel="stylesheet" type="text/css" th:href="@{/layout/plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css}">
<link rel="stylesheet" type="text/css" th:href="@{/layout/dist/css/adminlte.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/layout/plugins/sweetalert2-theme-bootstrap-4/bootstrap-4.min.css}">
<link rel="stylesheet" type="text/css" th:href="@{/stylesheets/vendors/bootstrap-datepicker.standalone.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/layout/stylesheets/algaworks.min.css}"/>
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body class="hold-transition sidebar-mini layout-fixed layout-navbar-fixed layout-footer-fixed text-sm" >
<input type="hidden" name="_csrf" th:value="${_csrf.token}"/>
<input type="hidden" name="_csrf_header" th:value="${_csrf.headerName}"/>
<div id="root" class="wrapper">
<div th:replace="layout/fragments/BarraNavegacao :: navbar"></div>
<div th:replace="layout/fragments/MenuLateral :: layout-sidebar"></div>
<div class="content-wrapper js-content" layout:fragment="conteudo"></div>
<div th:replace="layout/fragments/Footer :: layout-footer"></div>
</div>
<script th:src="@{/layout/plugins/jquery/jquery.min.js}"></script>
<script th:src="@{/layout/plugins/bootstrap/js/bootstrap.bundle.min.js}"></script>
<script th:src="@{/layout/plugins/overlayScrollbars/js/jquery.overlayScrollbars.min.js}"></script>
<script th:src="@{/layout/dist/js/adminlte.js}"></script>
<script th:src="@{/layout/plugins/sweetalert2/sweetalert2.min.js}"></script>
<script th:src="@{/javascripts/vendors/jquery.masknumber.min.js}"></script>
<script th:src="@{/javascripts/vendors/jquery.mask.min.js}"></script>
<script th:src="@{/javascripts/vendors/bootstrap-datepicker.min.js}"></script>
<script th:src="@{/javascripts/vendors/bootstrap-datepicker.pt-BR.min.js}"></script>
<script th:src="@{/javascripts/vendors/numeral.min.js}"></script>
<script th:src="@{/javascripts/vendors/pt-br.min.js}"></script>
<th:block layout:fragment="javascript-extra"></th:block>
</body>
</html>
Legal @thimor , grato pelo retorno.
Entendi.