What is the difference between <s: property ..> and $ {param}

In struts, I notice that there are two different ways to access variables. I'm curious what the difference is and when to use each one correctly. For example, suppose we set a variable height like this:

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

Now I can use it in 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?

+4
source share
2 answers

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

+6
source

You can also use $ {} inside another struts 2 tag. You cannot pin spacer tags to each other.

+3
source

All Articles