【问题标题】:Spring SAXParseExceptionSpring SAXParseException
【发布时间】:2015-08-15 20:33:42
【问题描述】:

我正在尝试使用 spring boot 开发一个应用程序,并且我有以下 html

<!doctype html>
<html ng-app>
<head>
<title>Hello AngularJS</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script>
<script src="hello.js"></script>
</head>

<body>
<div ng-controller="Hello">
<p>The ID is {{greeting.id}}</p>
<p>The content is {{greeting.content}}</p>
</div>
</body>
</html>

我收到此错误,但我不知道为什么,这与 https://spring.io/guides/gs/consuming-rest-angularjs/ 的示例中的代码相同

org.xml.sax.SAXParseException:与元素类型“html”关联的属性名称“ng-app”必须后跟“=”字符。

【问题讨论】:

标签: java angularjs spring spring-mvc


【解决方案1】:

这行对我来说似乎有问题

<html ng-app>

试试这条线

<html ng-app="">

因为如果你不想命名你的 angularJS 应用程序,那么声明为空。另外,我建议在bodytag 中使用ng-app="" 而不是html 标签

【讨论】:

  • 解决方案是按照 Maks 的建议添加 spring.thymeleaf.mode=LEGACYHTML5,是的,这也被证明是一个解决方案,但一直这样做很烦人
【解决方案2】:

我解决了这个问题。

将 application.properties "spring,thymeleaf.mode" 设置为 "LEGACYHTML5"。

spring.thymeleaf.mode=LEGACYHTML5

并在 pom.xml 中添加依赖:

<dependency>
  <groupId>net.sourceforge.nekohtml</groupId>
  <artifactId>nekohtml</artifactId>
  <version>1.9.22</version>
</dependency>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-19
    • 2014-07-31
    • 1970-01-01
    • 1970-01-01
    • 2012-06-02
    • 2012-08-20
    相关资源
    最近更新 更多