Eclipse 中 JSP 文件中的“Unknown tag (main)”警告

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35433161/
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-09-19 23:03:30  来源:igfitidea点击:

"Unknown tag (main)" warning in JSP file in Eclipse

eclipsehtmljsptags

提问by Redtama

I have this annoying behaviour with Eclipse where it warns me about the <main>element in my JSP file.

我在 Eclipse 中有这种烦人的行为,它警告我关于<main>JSP 文件中的元素。

I've got <!DOCTYPE html>at the top of my page and I'm using several other HTML5 elements, such as <header>and <footer>, but Eclipse doesn't give a warning about these.

我已经<!DOCTYPE html>在我的页面顶部,并且我正在使用其他几个 HTML5 元素,例如<header><footer>,但是 Eclipse 没有给出关于这些的警告。

I tried switching off HTML and JSP syntax validation but that didn't seem to work.

我尝试关闭 HTML 和 JSP 语法验证,但这似乎不起作用。

I just don't understand why it has a problem with the <main>tag but not other HTML5 tags and that little yellow underline is SUPER irritating.

我只是不明白为什么它的<main>标签有问题,但其他 HTML5 标签没有问题,那个黄色的小下划线非常令人恼火。

How can I get Eclipse to ignore this tag?

我怎样才能让 Eclipse 忽略这个标签?

Thank you in advance for your answers.

预先感谢您的回答。

回答by Redtama

So, it seems like people were having a similar problem with HTML5 attributes according to the question linked in the comment @safin chacko.

因此,根据@safin chacko 评论中链接的问题,人们似乎对 HTML5 属性有类似的问题。

The answers posted there show how you could get Eclipse to ignore validation of specified attributes. Since then it seems that Eclipse has the added feature of being able to also ignore validation of specified elements

那里发布的答案显示了如何让 Eclipse 忽略指定属性的验证。从那时起,Eclipse 似乎增加了能够忽略指定元素验证的功能

I have posted an answer on that questionwhich also answers my own question.

我在那个问题上发布了一个答案,它也回答了我自己的问题。

回答by Patrick

There appears to be a Bugzilla item for this already. Hopefully, when that is addressed, the problem will go away.

似乎已经有一个用于此的 Bugzilla 项目。希望当这个问题得到解决时,问题就会消失。

https://bugs.eclipse.org/bugs/show_bug.cgi?id=516758

https://bugs.eclipse.org/bugs/show_bug.cgi?id=516758

In the meantime, you can suppress the warning by going to Eclipse > Preferences > Web > HTML Files > Validation and adding main to the comma-separated list element names to be ignored.

同时,您可以通过转到 Eclipse > Preferences > Web > HTML Files > Validation 并将 main 添加到要忽略的逗号分隔列表元素名称来抑制警告。

回答by Pratik Roy

One of the cause for this warning might be you are using footer tag without a header tag.

此警告的原因之一可能是您使用的页脚标记没有页眉标记。

1.Create a separate file say "Footer.html" and write your footer content in that.

1.创建一个单独的文件说“Footer.html”并在其中写入您的页脚内容。

2.Include that footer.html in your main .jsp file through : <%@ include file="Footer.html"%>

2.通过:<%@include file="Footer.html"%>在您的主 .jsp 文件中包含该 footer.html

You can try the same for header also.

您也可以尝试相同的标题。