vendredi 24 mars 2017

Spring ThymeLeaf throws TemplateProcessingException: Invalid syntax in DOM selector when passing fragment

I'm writing Spring application using ThymeLeaf. I've got a lot of code that is repeated so I try to divide code.

I've got: templates/profile.html:

<!DOCTYPE html>
<html xmlns="http://ift.tt/lH0Osb"
  lang="en">
    <head th:replace="html/common/head :: head('User Profile', ~{html/profile/style-list :: style-list}"></head>

<body></body>

templates/profile/style-list.html:

<!DOCTYPE html>
<html xmlns="http://ift.tt/lH0Osb"
  lang="en">
    <th:block th:fragment="style-list">
        <link rel="stylesheet" th:href="@{css/profile.css}" type="text/css">
    </th:block>
</html>

templates/common/head.html:

<!DOCTYPE html>
<html xmlns="http://ift.tt/lH0Osb"
  lang="en">
    <head th:fragment="head(title, css)">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title th:text="${name}"></title>

        <base href="/" />

        <link rel="stylesheet" th:href="@{css/bootstrap.css}" type="text/css"/>
        <link rel="stylesheet" th:href="@{css/common/header.css}" type="text/css"/>
        <link rel="stylesheet" th:href="@{css/common/footer.css}"  type="text/css"/>

        <th:block th:replace="${css}" />
    </head>
</html>

CSS files are existing and containing some styles.

The problem is that I am getting server error:

org.thymeleaf.exceptions.TemplateProcessingException: Invalid syntax in DOM selector "/css.html :: css}": selector does not match selector syntax: ((/|//)?selector)?([@attrib="value" (and @attrib2="value")?])?([index])? (profile:4)

I have no idea how to fix it. Problem is that thymeleaf code structure is the same as in Spring Boot application I've written some time ago.

Thank you!

Aucun commentaire:

Enregistrer un commentaire