Eclipse Ganymede not validating JSPs properly

2019-03-27 09:14发布

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 -

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?

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

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"%>

8条回答
我欲成王,谁敢阻挡
2楼-- · 2019-03-27 09:39

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

查看更多
倾城 Initia
3楼-- · 2019-03-27 09:40

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...

<form:errors path="*" />

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

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

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

查看更多
唯我独甜
4楼-- · 2019-03-27 09:44

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.

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.

查看更多
Anthone
5楼-- · 2019-03-27 09:55

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?

查看更多
Viruses.
6楼-- · 2019-03-27 09:58

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

查看更多
一纸荒年 Trace。
7楼-- · 2019-03-27 09:58

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

<%  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.

查看更多
登录 后发表回答