【问题标题】:Grails g:each , Using fieldvalue or direct access DifferenceGrails g:each ,使用字段值或直接访问差异
【发布时间】:2013-08-08 07:25:31
【问题描述】:
<g:each in="${business}" status="i" var="businessInstance">
<tr class="${(i % 2) == 0 ? 'odd' : 'even' }">
<td>${fieldValue(bean: businessInstance, field: "id") }</td>
<td>${businessInstance.id}</td>
</tr>
</g:each>

在上面的示例中,第一个和第二个表数据的结果相同。这两种情况有什么区别吗?

【问题讨论】:

    标签: grails gsp


    【解决方案1】:

    fieldValue 通过调用encodeAsHTML() 对值进行转义以防范XSS 攻击,因此使用起来更加安全。它还根据当前区域设置格式化数字。

    【讨论】:

    • 配置 grails.views.default.codec = 'html' 是否会使 ${} 充当 ${fieldValue}(我正在使用 Grails 2.2.0?)?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-05
    • 1970-01-01
    相关资源
    最近更新 更多