Eclipse Ganymede 未正确验证 JSP

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

Eclipse Ganymede not validating JSPs properly

javaeclipsevalidationjspganymede

提问by bpapa

I just installed Ganymede and am exploring an old project in it. All of my JSPs are giving me weird validation errors. I'm seeing stuff like -

我刚刚安装了 Ganymede 并且正在探索其中的一个旧项目。我所有的 JSP 都给了我奇怪的验证错误。我看到的东西像 -

Syntax error on token "}", delete this token
Syntax error on token "catch", Identifier expected
Syntax error, insert "Finally" to complete TryStatement

I'm doing best practice stuff here, no scriplets or anything, so I think that Eclipse is incorrectly applying a Java class validator to my JSPs. Any idea on how to stop that from happening?

我在这里做的是最佳实践,没有脚本或任何东西,所以我认为 Eclipse 错误地将 Java 类验证器应用于我的 JSP。关于如何阻止这种情况发生的任何想法?

Under Options/Editors/File Associations I have the following for JSPs:

在选项/编辑器/文件关联下,我对 JSP 有以下内容:

JSP Editor (default)
Web Page Editor
Text Editor
CSS JSP Editor

Am I missing something?

我错过了什么吗?

Also I think this is correct, but just in case it's not, here is my page directive -

我也认为这是正确的,但以防万一,这是我的页面指令 -

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>

采纳答案by nitind

I have just downloaded Ganymede 3.4.2 and added WTP 3.0.4 to it and this error has gone for me.

我刚刚下载了 Ganymede 3.4.2 并将 WTP 3.0.4 添加到它,这个错误对我来说已经消失了。

回答by Greg

I actually found out what my problem was through the eclipse webtools usergroup. The issue for me was the use of the Spring form custom tag library. If you self-close the tag...

我实际上通过eclipse webtools 用户组发现了我的问题。我的问题是使用 Spring 表单自定义标记库。如果您自行关闭标签...

<form:errors path="*" />

...then you get the goofy JSP validation error. If you close the tag as if there was body content...

...然后你会得到愚蠢的 JSP 验证错误。如果关闭标签就像有正文内容一样......

<form:errors path="*"></form:errors>

Then the error goes away. I need to follow-up with a bug for the Ganymede team.

然后错误消失。我需要跟进 Ganymede 团队的一个错误。

回答by nitind

It's not actually something about the editor itself.

这实际上与编辑器本身无关。

This usually happens because of
A) custom tags that are missing a start or end tag cause an imbalance in the translation
or
B) is the result improper handling of scripting variable for custom tags by the JSP Validator.

这通常是因为
A) 缺少开始或结束标记的自定义标记导致翻译不平衡

B) 是 JSP 验证器对自定义标记的脚本变量处理不当的结果。

One's a fault in the JSP file and the other's the fault of the validator. Neither will cause this problem in the upcoming WTP 3.0.3 and Ganymede SR2 releases.

一个是 JSP 文件的错误,另一个是验证器的错误。在即将发布的 WTP 3.0.3 和 Ganymede SR2 版本中都不会导致此问题。

回答by Gopal Bairwa

I just ran a update for Software Updates->Gynemede Update Site-> "Web and Java EE Development" and the error seems to go away.

我刚刚运行了软件更新-> Gynemede 更新站点->“Web 和 Java EE 开发”的更新,错误似乎消失了。

回答by Jorn

Under preferences -> editors -> file associations, you can see which editor(s) are associated with .jsp files. Perhaps it got associated with a wrong editor, and content checking. You can find a reasonably good JSP editor in the Web Tools Platform (WTP) toolkit.

在首选项 -> 编辑器 -> 文件关联下,您可以看到哪些编辑器与 .jsp 文件相关联。也许它与错误的编辑器和内容检查有关。您可以在 Web Tools Platform (WTP) 工具箱中找到相当不错的 JSP 编辑器。

回答by Greg

I have the same issue. Whatever JSP editor is in Ganymede does not like my if/else scriptlets:

我有同样的问题。Ganymede 中的任何 JSP 编辑器都不喜欢我的 if/else 脚本:

<%  if(message != null) { %>
    <p id="message"><%=message %></p>
<%  } else { %>
    <p>Please login to view your account information.</p>
<%  } %>

It tells me:

它告诉我:

Syntax error on token "}", delete this token
Syntax error on token "catch", Identifier expected
Syntax error, insert "Finally" to complete TryStatement

...on the final closing brace. I have the same file associations as the original poster. I suppose I will try to find another JSP editor in the WTP toolkit, but I was under the impression that came with my build.

...在最后一个大括号上。我与原始海报具有相同的文件关联。我想我会尝试在 WTP 工具包中找到另一个 JSP 编辑器,但我的印象是随我的构建而来。

回答by Greg

This is unfortunately a known bug apparently introduced in Service Release 1 of Ganymede (Eclipse Ganymede SR1, v 3.4.1).

不幸的是,这是 Ganymede 服务版本 1(Eclipse Ganymede SR1,v 3.4.1)中明显引入的已知错误。

See the following pages for more information:

有关更多信息,请参阅以下页面:

http://www.coderanch.com/t/106846/IDEs-Version-Control-other-tools/Ganymede-bug-using-jsp-include

http://www.coderanch.com/t/106846/IDEs-Version-Control-other-tools/Ganymede-bug-using-jsp-include

http://www.eclipse.org/newsportal/article.php?id=17447&group=eclipse.webtools#17447

http://www.eclipse.org/newsportal/article.php?id=17447&group=eclipse.webtools#17447

The bug is fixed in WTP 3.0.3. Note that to get the fix through the Eclipse "Software Updates" function, you have to manually add the WTP update site to the list of sites that get searched during updates, by using the "Maage Sites..." function and check the Eclipse Webtools site.

该错误已在 WTP 3.0.3 中修复。请注意,要通过 Eclipse 的“软件更新”功能获得修复,您必须手动将 WTP 更新站点添加到更新期间搜索的站点列表中,使用“Maage 站点...”功能并检查 Eclipse网站工具。

回答by Greg

Hm, I upgraded to 3.0.3, to no effect. This is happening mostly for <%@ include file="somefile.jsp" %> -style includes. Incredibly frustrating -- makes it very hard to find real errors when I have 300+ of these. Anyone have any luck going back to an earlier version of WTP?

嗯,我升级到3.0.3,没有效果。这主要发生在 <%@ include file="somefile.jsp" %> 样式的包含中。令人难以置信的沮丧——当我有 300 多个错误时,很难找到真正的错误。任何人有运气回到早期版本的 WTP 吗?