Html 实体名称必须紧跟在'&';
我在openshift(tomcat 7)上部署我的webapp,但出现错误:Html 实体名称必须紧跟在'&';,html,xml,spring-mvc,openshift,thymeleaf,Html,Xml,Spring Mvc,Openshift,Thymeleaf,我在openshift(tomcat 7)上部署我的webapp,但出现错误: HTTP Status 500 - Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Exception parsing document: template="null", line 2 - column 23 (dodaj:42) org.xml.sax.SAXParse
HTTP Status 500 - Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Exception parsing document: template="null", line 2 - column 23 (dodaj:42)
org.xml.sax.SAXParseException; lineNumber: 2; columnNumber: 23; The entity name must immediately follow the '&' in the entity reference.
以及此错误的代码:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<title></title>
<meta name="description" content="HTML 5 CSS 3 Spring Form"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<link rel="stylesheet" href="../../css/style.css" th:href="@{/css/style.css}"/>
<script src="../../js/libs/modernizr-2.0.6.min.js" th:src="@{/js/libs/modernizr- 2.0.6.min.js}"></script>
</head>
............
<tr>
<td width="100px"><b>CATEGORY:</b></td>
<td width="400px">
<select th:field="*{category.name}" >
(this is line 42) <option th:each="c : ${category}" th:value="${c.name}" th:utext="${c.name}">
</option>
</select>
</tr>
............
类别:
(这是第42行)
我搜索了解决方案,但没有找到。在我的本地主机上运行良好。也许有人也有类似的问题。谢谢,我解决了这个问题。问题出在我的数据库里。在类别名称中,我得到了例如“教育与科学”和thymeleaf在``中遇到了“&”的问题:
我把它改为“and”,所有的东西都能用。不确定“dodaj”是什么意思,但消息说错误在第2行。这是我的html名称“dodaj.html”。我认为第2行(嗯。当你得到错误时,你能看看生成的HTML源代码吗?或者你得到的只是错误消息吗?为什么你不使用
th:text
而不是th:utext
?我希望它能正常工作。否则对我来说它看起来像个bug。
<option th:each="c : ${category}" th:value="${c.name}" th:utext="${c.name}">