Spring Boot integrated with Thymeleaf- namespace 'th' is not found

When we create a html file in the templates directory in a spring boot project integrated with Thymeleaf view, we will find the namespace ‘th’ is unavailable.
If you hover your mouse to see the hint, it will alert like this: namespace ‘th’ is not found.
The reason for this is, your manually created html doesn’n include the xmlns into this html file. while xmlns stands for ‘xml name space’. like this
在這裏插入圖片描述
So here is we are gonna do, just include this two lines into the html tag

<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>first thymeleaf demo</title>
</head>
<body>
    <span th:text="Hello"></span>
    <hr/>
    <span th:text="${msg}"></span>
</body>
</html>

Problem solved.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章