【问题标题】:Undefined attribute name (role) , eclipse未定义的属性名称(角色),eclipse
【发布时间】:2018-09-03 05:05:32
【问题描述】:

我有以下文件结构

WebContent->引导程序->

js

css

图片

WebContent->index.jsp

以下两个网址均无助于解决未定义属性错误。

Undefined attribute name (data-toggle)

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">

<button type="submit" class="btn btn-default">Submit</button>
<span class="label label-primary">Primary</span>
<span class="label label-success">Success</span>
<span class="label label-info">Info</span>
<span class="label label-warning">Warning</span>
<span class="label label-danger">Danger</span>
<a href="#">Inbox <span class="badge">42</span></a>


</div>
<div class="jumbotron">
  <h1>Hello, world!</h1>
  <p>...</p>
  <p><a class="btn btn-primary btn-lg" role="button">Learn more</a></p>
</div>

<div class="dropdown">
  <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
    Dropdown
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
    <li role="presentation" class="divider"></li>
    <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
  </ul>
</div>
</body>
</html>

Eclipse 版本详细信息如下所列。 Spring工具套件

版本:3.6.1.RELEASE 内部版本号:201408250818 平台:Eclipse Luna (4.4)

版权 (c) 2007 - 2014 Pivotal Software, Inc. 版权所有。访问http://spring.io/tools/sts

本产品包括由 阿帕奇软件基金会http://www.apache.org

【问题讨论】:

  • 这是哪个版本的 Eclipse?数据切换在这个版本的 HTML 中有效吗?这两个网址中的第二个是什么?

标签: jquery eclipse twitter-bootstrap undefined


【解决方案1】:

您的文档类型

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

适用于 HTML 4.01。

data-* attributes 是在 HTML 5 中添加的。The doctype for HTML 5 基本上是两者之一

<!DOCTYPE html>

<!DOCTYPE html SYSTEM "about:legacy-compat">

您的 IDE 也很可能不了解 HTML 5 及其许多变化。

【讨论】:

    【解决方案2】:

    较新版本的 Eclipse 支持 HTML5 标记和 HTML5 中允许的 data-* 属性。但是,根据 ARIA 角色模型和 XHTML 角色属性模块使用角色属性时,正确的语法是不要在角色属性前面加上 data-*,只留下角色而不是数据角色。

    所以&lt;ul role="menubar"&gt;&lt;ul data-role="menubar"&gt; 更正确。可以使用 (X)HTML5 Validator 检查语法的有效性。 jQuery Mobile 相当广泛地使用了 data-role 属性,虽然我不知道为什么。

    注意:如果您升级后仍然收到有关 data-* 属性的警告,您可能需要考虑更新或删除任何已安装的语法检查器,例如 JTidy。从 Indigo Service Release 1 开始,角色属性默认继续在 Eclipse 中触发未定义属性警告。

    【讨论】:

      【解决方案3】:

      我在使用 Eclipse-Helios 时遇到了同样的问题,这就是我所做的:

      从工具栏:

      窗口>首选项>Web>验证>属性,

      那就换

      “未定义的属性名称”

      来自

      '错误'

      '警告'

      '忽略'

      .

      helios.png

      【讨论】:

        猜你喜欢
        • 2015-02-01
        • 1970-01-01
        • 2016-05-18
        • 2012-09-16
        • 2023-02-01
        • 1970-01-01
        • 1970-01-01
        • 2017-10-21
        • 1970-01-01
        相关资源
        最近更新 更多