为什么 Eclipse 会在 HTML 脚本标签上创建警告?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4268976/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:26:45  来源:igfitidea点击:

Why does Eclipse creates warning on HTML script tag?

htmleclipsewarnings

提问by Matthieu Napoli

I have a warning on the line including the javascript file.

我在行上有一个警告,包括 javascript 文件。

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
        <title></title>
        <script type="text/javascript" src="scripts/jquery.js"></script>
    </head>
    <body>

The warning is "Multiple annotations found at this line: - Undefined attribute name (src). - Undefined attribute name (type)."

警告是“在这一行找到多个注释:- 未定义的属性名称(src)。- 未定义的属性名称(类型)”。

I can't see where the problem is!

我看不出问题在哪里!

采纳答案by John Giotta

It's the doc type. Eclipse is going to validate the DOM against the DTD. If unknown entities are not clearly defined in the DTD, then Eclipse will raise warnings.

这是文档类型。Eclipse 将根据 DTD 验证 DOM。如果未知实体未在 DTD 中明确定义,则 Eclipse 将发出警告。

回答by nitind

In the absence of an explicit doctype, you should check if the Property dialog for the file has a page for deciding what doctype to use as a default. HTML5 was only very recently added: http://dev.eclipse.org/mhonarc/lists/wtp-dev/msg07790.html.

在没有明确的文档类型的情况下,您应该检查文件的属性对话框是否有一个页面来决定使用什么文档类型作为默认值。HTML5 是最近才添加的:http: //dev.eclipse.org/mhonarc/lists/wtp-dev/msg07790.html

回答by timca

Instead of <!DOCTYPE html>, using this <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

而不是<!DOCTYPE html>,使用这个 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">