struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Li Ying <liying.cn.2...@gmail.com>
Subject Re: Incorrect test syntax
Date Fri, 24 Sep 2010 14:15:52 GMT
Hi Michael:

Or you can use another simple solution:

Convert the value to String(by invoke the [toString] method),
before you can compare it to the String constant.

In your case, it should be:

<s:if test="config.project.toString() == 'dba2'">
...



2010/9/24 Li Ying <liying.cn.2010@gmail.com>

> Hi Michael:
>
> I think changing the return type from Enum to String is not a very good
> solution.
> It maybe make your JSP get work,but your Java code will become a little
> ugly.
>
> I think the better way is:
> (1)do not chang the return type of config.getProject().
> (2)in tag <s:if>, compare it to an enum constant, rather than a string
> constant.
>
> in your case, it should be:
>
> ...
> <s:if test="project == @YourFullPackageName.Project@dba2">
> ...
>
> check this page:
> http://www.opensymphony.com/ognl/html/LanguageGuide/staticFields.html
> to see the syntax to reference [Static Fields] in OGNL.
>
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message