在 Eclipse 中为 Java EE 开发人员版禁用 HTML 警告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1918020/
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
Disable HTML Warnings in Eclipse for Java EE developers edition
提问by Bernie Perez
I am working on a Web App with Eclipse for Java EE. I have JSP files that are built with HTML files as includes. My index.jsp looks like this:
我正在使用 Eclipse 为 Java EE 开发一个 Web 应用程序。我有使用包含的 HTML 文件构建的 JSP 文件。我的 index.jsp 看起来像这样:
<jsp:include page="include/top.html" />
<title>Title!</title>
<jsp:include page="include/header.html" />
<jsp:include page="include/menu.html" />
<div class="span-15 prepend-1 last">
<h6>What is an <a href="http://en.wikipedia.org/wiki/Application_programming_interface">API</a>?</h6>
<p>An application programming interface (API) is an interface that software programs implement in order to allow other software to interact with it; much in the same way that software might implement a User interface in order to allow humans to interact with it.</p>
</div>
<jsp:include page="include/footer.html" />
The problem is with the includes. footer.htmlLooks like this:
问题在于包含。footer.html看起来像这样:
<hr />
<h3 class="alt"><b><a href="/copyright.html">Copyright</a> © 2009</b> My Company. All rights reserved.</h3>
<hr />
<p>
Visit <a href="/">Home</a>
</p>
</div>
</body>
</html>
Which gets put at the bottom of most pages. And I'm really annoyed with these warning messages like Invalid location of tag (body).
I know its invalid within this file but the other side belongs with header.html.
它放在大多数页面的底部。我对这些警告消息真的很恼火,就像Invalid location of tag (body).
我知道它在这个文件中无效,但另一端属于 header.html。
In Java classes you can suppress warnings with things like @SuppressWarnings("serial")
... Any way to do something like this with these HTML or JSP files?
在 Java 类中,您可以使用以下内容来抑制警告@SuppressWarnings("serial")
... 有没有办法对这些 HTML 或 JSP 文件执行此类操作?
采纳答案by ChssPly76
- Right click on your project,
Properties
->Validation
(or you can go toWindow
->Preferences
->Validation
to do this globally). - Uncheck "Build" for HTML syntax validation OR
- Click ellipsis under "Settings" and add a rule to exclude specific file name / extension / what have you
- 右键单击您的项目,
Properties
->Validation
(或者您可以转到Window
->Preferences
->Validation
全局执行此操作)。 - 取消选中“构建”以进行 HTML 语法验证或
- 单击“设置”下的省略号并添加规则以排除特定文件名/扩展名/你有什么
回答by user233238
im using myeclipse and at window->preferences->validation->jsp there is bunch of choices
我使用 myeclipse 并且在 window->preferences->validation->jsp 有很多选择
回答by Jared Russell
The only way that I'm aware of to solve this is to disable HTML validation for the project. Right click the project in question and go to properties, then go to the validation menu. You can either disable all HTML validation or go into the "HTML Syntax" validation sub-menu and disable individual problems.
我知道解决这个问题的唯一方法是禁用项目的 HTML 验证。右键单击有问题的项目并转到属性,然后转到验证菜单。您可以禁用所有 HTML 验证或进入“HTML 语法”验证子菜单并禁用个别问题。
回答by Brian
@ChssPly76 is correct, but I'd like to add that (using Mars), after following those steps, I was also required to re-validate the project to remove the warnings in the Problemssection (right click project, validate).
@ChssPly76 是正确的,但我想补充一点(使用 Mars),在遵循这些步骤之后,我还需要重新验证项目以删除问题部分中的警告(右键单击项目,验证)。
回答by mike rodent
2018-01-07: Eclipse Oxygen.
2018-01-07:Eclipse 氧气。
Things may have changed in this regard since 2009, because what I find at the moment is that you can tweak HTML errors and warnings globally (Window --> Prefs --> Web --> HTML Files --> Validation), or you can tweak on a per-project basis: Project --> Properties --> Validation --> HTML Syntax.
自 2009 年以来,这方面的情况可能发生了变化,因为我目前发现您可以全局调整 HTML 错误和警告(窗口 --> 首选项 --> Web --> HTML 文件 --> 验证),或者您可以在每个项目的基础上进行调整:项目 --> 属性 --> 验证 --> HTML 语法。
For example I just set Text Regions --> Invalid text string to "Ignore" because I was getting spurious warnings for some Django HTML files with placeholders (or whatever they're called).
例如,我只是将 Text Regions --> Invalid text string 设置为“Ignore”,因为我收到了一些带有占位符(或任何名称)的 Django HTML 文件的虚假警告。
I also found that I was getting a warning for the hidden
attribute in DIVs: "your attribute should be followed by an = character". Oh dear: in HTML5 hidden
is a boolean
, Eclipse is therefore getting this wrong. I therefore set Attributes --> "Missing attribute equals sign character" to "Ignore" as well.
我还发现我收到了hidden
DIV 属性的警告:“你的属性后面应该跟一个 = 字符”。哦,亲爱的:在 HTML5 中hidden
是一个boolean
,因此 Eclipse 出错了。因此,我将属性-->“缺少属性等号字符”也设置为“忽略”。