more
more

Reputation: 133

Thymeleaf didn't load css and js

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?

Upvotes: 0

Views: 539

Answers (2)

more
more

Reputation: 133

We must use th:insert="~{fragments/layout.html}" instead of data-layout-decorate="~{fragments/layout.html}" at Thymeleaf version 3.0.9

Upvotes: 1

user3326775
user3326775

Reputation: 61

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).

Upvotes: 1

Related Questions