Actually my question is "My html page did not load layout.html Why?"
My page's head is
<!DOCTYPE html>
<html lang="en" data-layout-decorate="~{fragments/layout.html}">
<head>
<title>Plain Page</title>
</head>
My layout under fragments folder
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title data-layout-title-pattern="$LAYOUT_TITLE | $CONTENT_TITLE">Gentellela!</title>
<!-- Bootstrap -->
<link href="/webjars/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<!-- Font Awesome -->
<link href="/webjars/font-awesome/4.6.1/css/font-awesome.min.css" rel="stylesheet">
<!-- NProgress -->
<link href="/webjars/nprogress/0.2.0/nprogress.css" rel="stylesheet">
<!-- Custom Theme Style -->
<link href="/static/css/custom.min.css" rel="stylesheet">
</head>
If i run my project, just return html page (no css, no js)
Where is my fault?
I think the problem might be because of the closing of the meta tags.
Can you please close the meta tags and try. Like
I see there is no proper closing ("/" is missing).
We must use th:insert="~{fragments/layout.html}" instead of data-layout-decorate="~{fragments/layout.html}" at Thymeleaf version 3.0.9
Related
I am creating an email using Spring Boot and Apache FreeMarker. Is it possible to include CSS in the email without needing to have a huge tag in the header?
Here is an example .ftl file that I would like to link a .css file to:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="style.css">
<title>Hello, world!</title>
</head>
<body>
<div class="container">
<div class="style-in-css-doc">
Some text to be styled
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>
You can simply include the css file into your template by putting css code in another ftl file and then include it to your main template with include directive
<#include path>
when using thymeleaf, i created a seperate header and footer. but when i'm using it in another page it will generate error in IDE since xmlns:th="http://www.thymeleaf.org is not there. but the code is working in chrome. how can i eliminate error in IDE?
<!DOCTYPE html >
<html xmlns:th="http://thymeleaf.org">
<head th:fragment="head">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title> Data Tables</title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<link rel="stylesheet" th:href="#{/css/bootstrap.min.css}">
<link rel="stylesheet" th:href="#{/css/buttons.bootstrap.min.css}">
<link rel="stylesheet" th:href="#{/css/font-awesome.min.css}">
<link rel="stylesheet" th:href="#{/css/dataTables.bootstrap.min.css}">
<link rel="stylesheet" th:href="#{/css/fonts.css}">
<link rel="stylesheet" th:href="#{/css/AdminLTE.min.css}">
<link rel="stylesheet" th:href="#{/css/_all-skins.min.css}">
<link rel="stylesheet" th:href="#{/css/style.css}">
</head>
header.html
<div th:replace="fragments/head.html :: head "></div>
<div th:replace="fragments/header.html :: header"></div>
<div th:replace="fragments/sidenav.html :: sidenav"></div>
<div th:replace="fragments/footer.html :: footer"></div>
index.html
in index.html there is an error
I just started learning spring framework.
I have met a problem and decided to share it to help you.
First I added the project bootstrap library for a project.
Then I downloaded a free template from the Internet. I put the resources of this template in the project in the following location (see WebContent / WEB-INF / view / resources)
<%# page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%# taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>SB Admin - Start Bootstrap Template</title>
<!-- Bootstrap core CSS-->
<link href="${contextPath}/WebContent/WEB-INF/view/resources/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom fonts for this template-->
<link href="${contextPath}/WebContent/WEB-INF/view/resources/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- Custom styles for this template-->
<link href="${contextPath}/WebContent/WEB-INF/view/resources/css/sb-admin.css" rel="stylesheet">
</head>
Then I copied the codes of the login page from the source code into the project and defined the locations of the files used for HTML at the top.(you can see codes below)
When I compile and run my code, I do not have libraries added and I see a page with simple HTML code. What is wrong with me? How can I fix this problem? If you tell me my mistakes and you help me, I'm happy. Everyone thanks in advance
I solved the problem. First, in my project "application-context.xml"
I added the following code to the page. I moved my template files to "/ WebContent / resources / thema /" :
<mvc:resources mapping="/resources/**" location="/resources/thema/"
cache-period="31556926"/
I defined contextPath :
<c:set var="contextPath" value="${pageContext.request.contextPath}"/>
Don't forget to define this library for this :
<%# taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
After, I changed the path to the template folder in my .jsp file as follows:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>SB Admin - Start Bootstrap Template</title>
<!-- Bootstrap core CSS-->
<link href="${contextPath}/resources/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom fonts for this template-->
<link href="${contextPath}/resources/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<!-- Custom styles for this template-->
<link href="${contextPath}/resources/css/sb-admin.css" rel="stylesheet">
</head>
This solved my problem.
I got help here for the solution:
Browser can't access/find relative resources like CSS, images and links when calling a Servlet which forwards to a JSP
and
http://www.mkyong.com/spring-mvc/spring-mvc-how-to-include-js-or-css-files-in-a-jsp-page/
Thank you for your good help : Jorge Campos
I try to complete automatically my GeoNetwork catalog with java http post request. No matter the library (io, apache commons, geotools), I always have the same html response as follow.
<!DOCTYPE html
SYSTEM "html">
<html ng-app="gn_login" lang="eng" id="ng-app">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My GeoNetwork catalogue - My organization</title>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="description" content="">
<meta name="keywords" content="">
<link rel="icon" sizes="16x16 32x32 48x48" type="image/png" href="../../i$
<link href="rss.search?sortBy=changeDate" rel="alternate" type="applicati$
<link href="portal.opensearch" rel="search" type="application/opensearchd$
<link href="/geonetwork/static/gn_login_default.css" rel="stylesheet" med$
<link href="/geonetwork/static/bootstrap-table.min.css" rel="stylesheet" $
<link href="/geonetwork/static/ng-skos.css" rel="stylesheet" media="scree$
<link href="/geonetwork/static/srv_custom_style.css" rel="stylesheet" med$
</head>
<body data-ng-controller="GnCatController">
<div class="navbar navbar-default gn-top-bar" data-ng-hide="layout.hideTo$
<div data-ng-include="'../../catalog/templates/signin.html'"></div>
<div ng-include="'../../catalog/templates/info.html'"></div><script src="$
<div class="alert" data-ng-hide=""><strong></strong>
</div>
</noscript>
</body>
</html>
I start my GeoNetwork with jetty server. Do you know how to directly request the server to get an XML response?
Probably you are trying to make the request to a protected URL. You must make a request to the login service first, keep the JSESSIONID cookie it returns and then send it to the original service you wanted to request.
Netbeans HTML checking doesn't like my thymeleaf namespace.
Here is my HTML Thymleaf file:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="head">
<object th:include="fragments/meta :: meta" th:remove="tag" />
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700|Open+Sans:300italic,400,300,700' rel='stylesheet' type='text/css'/>
<link href="/../../../webjars/Semantic-UI/2.0.6/semantic.min.css" rel="stylesheet" th:href="#{/webjars/Semantic-UI/2.0.6/semantic.min.css}"/>
<link href="../../../css/core.css" rel="stylesheet" th:href="#{/css/core.css}" />
<link href="../../../css/product.css" rel="stylesheet" th:href="#{/css/product.css}" />
</head>
<body>
</body>
</html>
This is the error displayed in Netbeans:
How can I get Netbeans to play nicely with Thymeleaf?
Try to fix it in this way you may ignore spring security thing.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<meta charset="utf-8"/>
<title>Sample</title>
<link th:href="#{/resources/css/bootstrap.css}" rel="stylesheet" type="text/css"/>
<link th:href="#{/resources/css/bootstrap-theme.css}" rel="stylesheet" type="text/css"/>
</head>
I found out how to disable these errors when I was taking this spring security tutorial
Simply by adding this to html tag:
xmlns="http://www.w3.org/1999/xhtml"
what's even cooler, netbeans now tracks if you closed every tag with slash "/" in document.