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?
3 comments:
I believe, that always there is a possibility.
Cool fix!
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