You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Alex Siman <al...@gmail.com> on 2009/09/20 02:44:21 UTC

%{} confuses me

I must use ${} to evaluete expression either in .properties, struts.xml, java
strings - everywhere, but not in JSP. In JSPs I must use %{}. Damn.
Inconsistency.

Is there any workaround to use ${} instead of %{} in JSPs?

And more: 
  <s:url action="hello">
    <s:param name="name" value="'Struts2'"/>
  </s:url>

note ' (apostrophes) around the Struts2 word. So "value" attr supposes to
contain expression. But values of "action" and "name" attrs are just the
strings.

It would be nice to suppose every attr value is a string and using %{} we
can evaluate exp.
-- 
View this message in context: http://www.nabble.com/-%7B%7D-confuses-me-tp25526882p25526882.html
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: %{} confuses me

Posted by Dale Newfield <da...@newfield.org>.
${} is used to indicate that the content is to be evaluated using one 
specific language (JSTL EL).

%{} is used to indicate that the content is to be evaluated using 
*another* specific language -- in this case OGNL.

(Note, for historical reasons in struts.xml I believe the contents of 
both ${} and %{} are evaluated using OGNL -- use %{} in that so as not 
to confuse yourself.)

http://struts.apache.org/2.1.6/docs/ognl-basics.html
http://www.opensymphony.com/ognl/html/LanguageGuide/index.html

>   <s:url action="hello">
>     <s:param name="name" value="'Struts2'"/>
>   </s:url>

Do yourself a favor and ALWAYS use %{} where OGNL is expected, so you 
don't do something like value="Struts2" expecting it to be the literal 
'Struts2' and later find that it tried to evaluate that expression. 
value="%{'Struts2'}" is unambiguous:  it's an OGNL expression containing 
the string "Struts2".

-Dale

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