Reputation: 3086
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}"> </div>
..or..
<div style="height: <s:property value='#height' />"> </div>
What is the difference, and which is better to use?
Upvotes: 4
Views: 1789
Reputation: 4808
Also you can use ${} inside another struts 2 tag. You can not nestle struts tags inside each other.
Upvotes: 3
Reputation: 403501
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.
Upvotes: 6