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?
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.
Also you can use ${} inside another struts 2 tag. You can not nestle struts tags inside each other.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With