struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <davelnew...@gmail.com>
Subject Re: dumb question
Date Thu, 18 Oct 2018 13:46:35 GMT
You’re still enclosing a single character in single quotes in OGNL. I’m not
sure how else to say it. You need double-quotes around a single-character
string in OGNL for it to be a string, with single-quotes it will be
interpreted as a character, not a string.

On Thu, Oct 18, 2018 at 9:15 AM Greg Huber <gregh3269@gmail.com> wrote:

> return "\"" + "0" +"\"";
>
> This has the double quotes and does not seem to work with:
>
> <s:if test="select == '0'">
> <s:if test="select.equals('0')">
>
> Interestingly, this is the only one that does works:
>
> <s:if test="select.startsWith('0')">
>
> On Thu, 18 Oct 2018 at 12:51, Dave Newton <davelnewton@gmail.com> wrote:
>
> > Tests for single-char strings in OGNL need to be delimited by double
> > quotes, not single. Single quotes around a single-character string will
> be
> > compared as a char.
> >
> > On Thu, Oct 18, 2018 at 7:28 AM Greg Huber <gregh3269@gmail.com> wrote:
> >
> > > none seem to work?
> > >
> > > return "'" + "0" +"'";
> > > return "\"" + "0" +"\"";
> > > return "'0'";
> > >
> > > I am really testing for a 0 or a 1,  have had to fudged it by "0" +
> > > myvalue;
> > >
> > > public String getSelect() {
> > >         return "0" + myvalue;
> > >     }
> > >
> > > <s:if test="select == '00'">
> > > </s:if>
> > >
> > >
> > >
> > >
> > > On Thu, 18 Oct 2018 at 12:14, Lukasz Lenart <lukaszlenart@apache.org>
> > > wrote:
> > >
> > > > czw., 18 paź 2018 o 12:44 Greg Huber <gregh3269@gmail.com>
> napisał(a):
> > > > >
> > > > > Sorry if this is a dumb question, but why does a single char string
> > > check
> > > > > not work?  Am I missing something?
> > > > >
> > > > > this works:
> > > > > public String getSelect() {
> > > > >         return "az";
> > > > > }
> > > > > <s:if test="select == 'az'">
> > > > > </s:if>
> > > > >
> > > > > this does not:
> > > > > public String getSelect() {
> > > > >         return "a";
> > > > > }
> > > > > <s:if test="select == 'a'">
> > > > > </s:if>
> > > >
> > > > Probably it's because the 'a' in this case is a Char not String, try
> > > > to use "" instead to return Char from getSelect()
> > > >
> > > > <s:if test='select == "a"'>
> > > > </s:if>
> > > >
> > > > or
> > > >
> > > > public Char getSelect() {
> > > >         return 'a';
> > > > }
> > > >
> > > >
> > > > Regards
> > > > --
> > > > Łukasz
> > > > + 48 606 323 122 http://www.lenart.org.pl/
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> > > > For additional commands, e-mail: dev-help@struts.apache.org
> > > >
> > > >
> > >
> > --
> > em: davelnewton@gmail.com
> > mo: 908-380-8699
> > tw: @dave_newton <https://twitter.com/dave_newton>
> > li: dave-newton <https://www.linkedin.com/in/dave-newton/>
> > gh: davelnewton <https://github.com/davelnewton>
> > so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>
> > bl: Bucky Bits <http://buckybits.blogspot.com/>
> > sk: davelnewton_skype
> >
>
-- 
em: davelnewton@gmail.com
mo: 908-380-8699
tw: @dave_newton <https://twitter.com/dave_newton>
li: dave-newton <https://www.linkedin.com/in/dave-newton/>
gh: davelnewton <https://github.com/davelnewton>
so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>
bl: Bucky Bits <http://buckybits.blogspot.com/>
sk: davelnewton_skype

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