netbeans 7.0 在 Struts2 选择标记中显示错误..netbeans 版本 6.9 不显示此错误

发布于 2024-11-05 19:33:07 字数 409 浏览 1 评论 0原文

<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:
"}" ...
"." ...
"]" ...
">" ...
"<" ...
<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>

the error messages reads as below

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

溺渁∝ 2024-11-12 19:33:07

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

对于我(Netbeans IDE 7.0 RC1)来说,它编译得很好并且可以工作,尽管该行被标记为错误。如果 glassfish 不会执行 jsp,则以下链接显示如何在 JSP 2.1 容器中禁用 JSP EL(以下链接的底部)。

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

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

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

在此线程中找到: http://struts.1045723.n5.nabble.com/s2-JSF-JSP-EL-vs-OGNL-EL-td3528303.html< /a>

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


您可能只是展示问题,但可以肯定的是,如果您提供列表而不是地图,那么返回到服务器的值将与显示值。因此,以下内容会产生相同的选择框,并且不会产生错误:

<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(这对某些人来说不是一个有吸引力的选项)或显式声明映射(如图所示)。

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

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

Found in this thread: http://struts.1045723.n5.nabble.com/s2-JSF-JSP-EL-vs-OGNL-EL-td3528303.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>

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文