You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pedro Herrera <pe...@hotmail.com> on 2007/08/14 18:18:12 UTC

using ${ , # and %{

I´m very confused , when I must use ${ , # and %  ???? 
What are the situations to use each one ?


Thanks

Herrera

-- 
View this message in context: http://www.nabble.com/using-%24%7B-%2C---and--%7B-tf4268310.html#a12147735
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: using ${ , # and %{

Posted by Josh Vickery <jo...@vickeryj.com>.
${} is for writing JSP EL, while %{} is for writing OGNL.  Both serve
similar purposes, and if you have a servlet container that supports
JSP EL and are running Struts 2, they can be used almost
interchangeably.  For more details you can read up on the JSP EL:
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSPIntro7.html and
using OGNL with Struts 2:
http://struts.apache.org/2.0.9/docs/ognl.html and
http://struts.apache.org/2.0.9/docs/tag-syntax.html

Josh

On 8/14/07, yitzle <yi...@users.sourceforge.net> wrote:
> NOTE: This email assumes Struts 2. I'm not sure how Struts 1 works; it
> may or may not be the same
>
> On 8/14/07, Pedro Herrera <pe...@hotmail.com> wrote:
> >
> > I´m very confused , when I must use ${ , # and %  ????
> > What are the situations to use each one ?
> >
> > Thanks
> >
> > Herrera
>
> I had the same problem when I started.
> If you got a getVar() that struts can get the value of var from, you
> can refer to it like:
> <s:property value="%{var}" /> *
>
> If you make a reference, eg
> <s:url id="REFRESH" action="ThisAction" includeParams="none" />
> you can use the # to refer to it:
> <s:a href="%{#REFRESH}">
>
> # is used for map/lists:
> <s:radio name="allowThis" list="#{true:'Yes', false:'No'}" />
>
> ${} is used by JSP, not Struts, no I don't have any sample code to
> share regarding it.
>
> *I suspect in some cases you can refer to a Struts variable like:
> "var" without the "%{}" but I'm not sure when/where.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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


Re: using ${ , # and %{

Posted by yitzle <yi...@users.sourceforge.net>.
NOTE: This email assumes Struts 2. I'm not sure how Struts 1 works; it
may or may not be the same

On 8/14/07, Pedro Herrera <pe...@hotmail.com> wrote:
>
> I´m very confused , when I must use ${ , # and %  ????
> What are the situations to use each one ?
>
> Thanks
>
> Herrera

I had the same problem when I started.
If you got a getVar() that struts can get the value of var from, you
can refer to it like:
<s:property value="%{var}" /> *

If you make a reference, eg
<s:url id="REFRESH" action="ThisAction" includeParams="none" />
you can use the # to refer to it:
<s:a href="%{#REFRESH}">

# is used for map/lists:
<s:radio name="allowThis" list="#{true:'Yes', false:'No'}" />

${} is used by JSP, not Struts, no I don't have any sample code to
share regarding it.

*I suspect in some cases you can refer to a Struts variable like:
"var" without the "%{}" but I'm not sure when/where.

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