You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by GF <ga...@gmail.com> on 2008/01/08 11:32:29 UTC

[S2] simple question about s:set

The wiki says:

<s:set name="personName" value="person.name"/>
Hello, <s:property value="#personName"/>. How are you?

But how can I assign a string to a variable?

Something like:

<s:set name="personName" value="John Jackson"/>
Hello, <s:property value="#personName"/>. How are you?

I tried it but seems not to work..

Thanks

GF

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] simple question about s:set

Posted by GF <ga...@gmail.com>.
Oh.. Thanks so much!
You saved me from a lot of troubles.

If possibile it would be great to add it on the wiki page..
Thank you!

GF

> The value attribute is treated an OGNL expression so "John Jackson"
> means its trying to access a property with that name.
> Instead, you need to tell it you're using a string literal in OGNL:
>
> <s:set name="personName" value="%{'John Jackson'}"/>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: [S2] simple question about s:set

Posted by Jeromy Evans <je...@blueskyminds.com.au>.
GF wrote:
> But how can I assign a string to a variable?
>
> Something like:
>
> <s:set name="personName" value="John Jackson"/>
> Hello, <s:property value="#personName"/>. How are you?
>
> I tried it but seems not to work..
>
>
>   
The value attribute is treated an OGNL expression so "John Jackson" 
means its trying to access a property with that name.
Instead, you need to tell it you're using a string literal in OGNL:

<s:set name="personName" value="%{'John Jackson'}"/>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org