rss
twitter

Friday, May 27, 2011

Error in Struts2 OGNL expressions when migrating to Netbeans 7

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


Netbeans 7 will show the above error in jsp pages when migrating to Netbeans 7.0 from lower version for the following type of syntax.

 list="#{true:'On',false:'Off'}" 

But it will not affect the output of the JSP page.But in Netbeans 7.0 that particular line is is flagged with an error.

It is because Netbeans 7 using JSP EL 2.1. JSP EL 2.1 useing the # character now.So to define the map of values with struts2 tags we need to specify the class path with the map definition. like

 list="#@java.util.LinkedHashMap@{true:'On',false:'Off'}" 

I have used the above method in my project and got it worked. Is this a best solution? is there any alternate methods available for this?

Bookmark and Share

3 comments:

oem downloadable software September 27, 2011 at 2:47 AM  

I believe, that always there is a possibility.

John,  January 10, 2014 at 4:13 PM  

An even cleaner workaround is to put a space between # and {.
OGNL seems to have no problem with it:

list="# {true:'On',false:'Off'}"

Post a Comment

  © Blogger templates by Ourblogtemplates.com updated with zenplate.com tips

Back to TOP