我有这个工作正常的模板:
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" 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.0" />
<link rel="shortcut icon" th:href="@{/images/logo.png}" type="image/x-icon"/>
<title>Mystic River</title>
<link rel="stylesheet" th:href="@{/css/style.css}" />
<link rel="stylesheet" th:href="@{/css/responsive.css}" />
</head>
<body>
<!-- Header -->
<header class="header-wrapper header_fixed bg_transparent" id="header-wrapper">
....
</html>
但是使用时
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org" 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.0" />
<link rel="shortcut icon" th:href="@{/images/logo.png}" type="image/x-icon"/>
<title>Mystic River</title>
<link rel="stylesheet" th:href="@{/css/style.css}" />
<link rel="stylesheet" th:href="@{/css/responsive.css}" />
</head>
<body>
<!-- Header -->
<header th:class="header-wrapper header_fixed bg_transparent" id="header-wrapper">
我有这个错误:
Caused by: org.attoparser.ParseException: Could not parse as expression: "header-wrapper header_fixed bg_transparent" (template: "index" - line 14, col 13)
at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)
at org.attoparser.MarkupParser.parse(MarkupParser.java:257)
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)
... 48 more
Caused by: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "header-wrapper header_fixed bg_transparent" (template: "index" - line 14, col 13)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:131)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:62)
at org.thymeleaf.standard.expression.StandardExpressionParser.parseExpression(StandardExpressionParser.java:44)
你有
class="header-wrapper header_fixed bg_transparent"
在第一个模板中并且
th:class="header-wrapper header_fixed bg_transparent"
在第二个(注意
th:class
而不是class
)。 "header-wrapper header_fixed bg_transparent"
不是有效的 Thymeleaf 表达式。