JSP EL(表达式语言)导致Eclipse中的问题 [英] JSP EL (Expression Language) causing problems in Eclipse

查看:244
本文介绍了JSP EL(表达式语言)导致Eclipse中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统:Ubuntu 9.10。 Eclipse 3.5.1与Java EE 1.2.1(手动安装 - 非从突触)。 Web开发工具3.1.1

My system: Ubuntu 9.10. Eclipse 3.5.1 with Java EE 1.2.1 (manual install - NOT from synaptic). Web Developer Tools 3.1.1

我最近采用了别人的代码(动态Web项目),并在Eclipse中遇到了很多错误,警告和不正确的语法突出显示。我缩小了这四行代码(创建一个新的动态Web项目,然后是一个新的JSP页面,并将其放在正文中):

I've recently adopted someone else's code (a Dynamic Web Project), and run into lots of errors, warnings and incorrect syntax highlighting in Eclipse. I've narrowed it down to these 4 lines of code (create a new Dynamic Web Project, and then a new JSP page, and put this in the body):

${(1<2)? "" : "no"}
<%for (int i = 0; i < 5; i++) {%>
<div>${5}</div>
<%}%>

错误/警告/语法高亮显示


line1:黄色警告行在'<'下:文本字符串中使用无效的字符串
($ {(1 <2)?是没有})。

line1: yellow warning line under '<': Invalid character used in text string (${(1<2)? "yes" : "no"}).

line2:'f'下的红色错误行:
在这一行找到多个注释:1)语法错误,插入最后完成TryStatement。 2)语法错误,插入}完成ClassBody

line2: red error line under 'f': Multiple annotations found at this line: 1) Syntax error, insert "Finally" to complete TryStatement. 2) Syntax error, insert "}" to complete ClassBody

line2:红色错误行在')':令牌上的语法错误),尝试在此令牌之后

line2: red error line under ')': Syntax error on token ")", try expected after this token

line3:div下的黄色警告行:无结束标签(/ div)。

line3: yellow warning line under 'div': No end tag (/div).

line3:在闭合div的<下面的黄色警告行:在此行找到多个注释
:1)文本字符串($ {5}<%}%>)中使用的无效字符。 2)文本字符串中使用的字符无效($ {5}<%}%>)。

line3: yellow warning line under '<' of closing div: Multiple annotations found at this line: 1) Invalid character used in text string (${5} <%}%>). 2) Invalid character used in text string (${5} <%}%>).

line3:'/ div'是黑色和紫色(对于scriptlet代码?)而不是HTML代码的绿色

line3: '/div' is black and purple (for scriptlet code?) instead of green for HTML code

line4:打开和关闭scriplet标签'<%'和'%>'是黑色而不是橙色

line4: The opening and closing scriplet tags '<%' and '%>' are black instead of orange

页面按照预期在浏览器中工作:你得到'5'五次。如果将第1行的空引号更改为是,则保存,关闭编辑器中的文件,r在项目资源管理器中单击它,然后重新打开它:所有错误/警告/错误的语法突出显示消失,除外第一个(无效字符)。这是令人难以置信的刺激。任何想法将不胜感激。

The page works as expected in a browser: you get '5' five times. If you change the empty quotes on line 1 to "yes" then save, close the file in the editor, r click it in the project explorer > validate, then re-open it: all errors / warnings / incorrect syntax highlighting disappear, except the first one (invalid character). This is incredibly irritating. Any thoughts would be greatly appreciated.

推荐答案

Eclipse WTP非常棒,但这个问题是一个 epic fail 在Eclipse WTP中也是如此。他们似乎正在努力,但直到那时,我只是通过 Web > JSP文件禁用/设置忽略与工作区首选项中的这些内容相关的所有验证。 >> 验证滚动列表到底部,并将所有EL验证设置设置为Ignore。同样在主要的验证首选项中,取消选中与JSP相关的所有复选框。然而,这似乎并没有消除每一个警告/错误,但是它至少使烦恼最小化。

Eclipse WTP is great, but exactly this problem is an epic fail in Eclipse WTP for me as well. They seem to be working on that, but until then I just disable/set-to-ignore all of the validation related to this stuff in the workspace preferences through Web > JSP Files > Validation > scroll list to very bottom and set all EL validation settings to Ignore. Also in the main Validation preference uncheck all checkboxes related to JSP. This however doesn't seem to remove every warning/error, but it at least minimizes the annoyance.

IntelliJ IDEA 更好地处理JSP / EL验证。

IntelliJ IDEA handles JSP/EL validation much better.

对我来说,症状使我认为WTP正在使用正则表达式而不是基于堆栈的解析器来验证HTML / JSP / EL。这是一个 big no-no ,如果是结构化标记。

To me, the symptoms make me think that WTP is using regexp instead of a stackbased parser to validate HTML/JSP/EL. This is a big no-no in case of structured markup.

这篇关于JSP EL(表达式语言)导致Eclipse中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆