netbeans 7.0显示Struts2选择标记中的错误.. netbeans版本6.9不显示此错误 [英] netbeans 7.0 shows error in Struts2 select tag .. netbeans version 6.9 does not show this error

查看:108
本文介绍了netbeans 7.0显示Struts2选择标记中的错误.. netbeans版本6.9不显示此错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<s:select
  name="PenaltyPercentage"
  id="PenaltyPercentageId"
  list="#{'7.5%':'7.5%', '15.0%':'15.0%'}" <!-- shows error in this line -->
  headerKey=""
  headerValue="Please Select"
  emptyOption="false">
</s:select>

错误消息如下所示

Encountered ":" at line 1, column 9.
Was expecting one of:
"}" ...
"." ...
"]" ...
">" ...
"<" ...


推荐答案

Netbeans 7使用JSP EL 2.1使用它#字符现在。

Netbeans 7 uses JSP EL 2.1 which uses the # character now.

对于我(Netbeans IDE 7.0 RC1),虽然该行标记有错误,但编译正常并且有效。如果glassfish不执行jsp,则以下链接显示如何在JSP 2.1容器中禁用JSP EL(以下链接的底部)。

For me (Netbeans IDE 7.0 RC1) it compiles fine and works although the line is flagged with an error. If glassfish will not execute the jsp then the following link shows how to disable JSP EL in a JSP 2.1 container (bottom of the following link).

http://struts.apache.org/2.0.14/docs/ognl.html

此时最简单的解决方案可能是添加地图类:

Probably the easiest solution at this time is to add the class of the map:

#@java.util.LinkedHashMap@{ "foo" : "foo value", "bar" : "bar value" } 

在此主题中找到: http://struts.1045723.n5.nabble.com/s2-JSF-JSP-EL-vs-OGNL-EL-td3528303.html

有关JSP EL 2.1的信息,请参阅: http: //jcp.org/aboutJava/communityprocess/final/jsr245/index.html

For information on the JSP EL 2.1 See: http://jcp.org/aboutJava/communityprocess/final/jsr245/index.html

你可能是只是笑解决问题,但只是为了确保,如果您提供列表而不是地图,则返回到服务器的值将与显示的值相同。因此,以下内容生成相同的选择框并且不会产生错误:

You are probably just showcasing the issue but just to be sure, if you supply a list rather than a map then the value returned to the server will be the same as the displayed value. So the following produces the same select box and does not produce an error:

<s:select
  list="{'7.5%','15.0%'}" <!-- does not show error -->
  headerValue="Please Select"
  emptyOption="false">
</s:select>

我花了一点时间看看我是否可以在Netbeans 7中更改JSP EL版本但是没有成功试图找到一种方法来禁用JSP EL错误检查但没有成功。因此,如果您必须在JSP中使用OGNL映射,请禁用JSP EL(对于某些人来说这不是一个有吸引力的选项)或显式声明地图如图所示。

I spent a little time seeing if I could change the JSP EL version in Netbeans 7 without success, also tried to find a way to disable JSP EL error checking without success. So if you must use OGNL maps in your JSP either disable JSP EL (which isn't an attractive option for some) or explicitly declare the map as shown.

这篇关于netbeans 7.0显示Struts2选择标记中的错误.. netbeans版本6.9不显示此错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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