< s:property ..>和有什么区别?和$ {param} [英] What's the Difference Between <s:property ..> and ${param}
本文介绍了< s:property ..>和有什么区别?和$ {param}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在struts中,我注意到有两种访问变量的不同方法.我很好奇这是什么区别,以及何时正确使用它们之间的区别.例如,假设我们像这样设置变量高度:
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?
推荐答案
struts2 <property>
提供了除${}
提供的功能之外的其他功能,例如,如果变量为null,则提供默认值,并控制HTML转义
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.
这篇关于< s:property ..>和有什么区别?和$ {param}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文