【问题标题】:Stackoverflow error on using twitter bootstrap attributes in element tag在元素标签中使用 twitter 引导属性时出现 Stackoverflow 错误
【发布时间】:2014-08-19 15:21:18
【问题描述】:

我在 Spring Boot 项目中使用最新版本的 Thymeleaf。我遇到了一个非常奇怪的问题,当我在元素标记中使用autofocusrequired 属性时,我遇到了stackoverflow 错误。我正在使用最新版本的Twitter Bootstrap 项目。在我的项目中,我正在使用:Spring Security、ThymeLeaf 和 Twitter Bootstrap。配置是使用 Java 配置完成的。下面是产生stackoverflow的代码。如果我删除 autofocusrequired 属性,应用程序运行良好。

<form class="form-signin" role="form">
    <h2 class="form-signin-heading">Please sign in</h2>
    <input type="email" class="form-control" placeholder="Email address" required autofocus>
    <input type="password" class="form-control" placeholder="Password" required>
    <label class="checkbox">
        <input type="checkbox" value="remember-me"> Remember me
    </label>
    <button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
</form>

【问题讨论】:

  • 请将堆栈跟踪添加到您的问题中。您的 HTML sn-p 没有给出任何错误的线索。
  • 因为它是一个堆栈溢出,所以跟踪消息很长。我创建了一个 GIST,可在以下地址获得:gist.github.com/5db/47a5b163fd8054d39a81
  • 您是否尝试过使用符合 XML 标准的标签,例如 required="required"autofocus="autofocus"
  • 是的,这行得通。它看起来像 ThymLeaf 库中的一个错误。
  • 这不是错误。如果您阅读手册,Thymeleaf 要求符合 XML。

标签: spring twitter-bootstrap spring-mvc spring-security thymeleaf


【解决方案1】:

Thymleaf 要求符合 XML。这意味着关闭标签和带有值的属性。您可以使用:

required="required" autofocus="autofocus"

将答案添加为 Bart 的回复对我有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-06-14
    • 2020-01-16
    • 2021-08-24
    • 1970-01-01
    • 2023-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多