views:

184

answers:

2

In struts I notice there are two different ways to access variables. I am curious what the difference is and when to properly use each one. For example, suppose we set the variable height like so:

<s:set var="height">300px</s:set>

Now I can use it two ways:

<div style="height: ${height}">&nbsp;</div>

..or..

<div style="height: <s:property value='#height' />">&nbsp;</div>

What is the difference, and which is better to use?

+3  A: 

The struts2 <property> provides additional functionality beyond what ${} offers, such as providing a default value if the variable is null, and control over HTML-escaping.

skaffman
A: 

Also you can use ${} inside another struts 2 tag. You can not nestle struts tag inside each other.