gpt4 book ai didi

grails - 如何从 Controller 设置gsp元素属性值

转载 作者:行者123 更新时间:2023-12-02 15:00:29 25 4
gpt4 key购买 nike

我有一个字段,可以存储带有html标签和完整格式的数据。例如:字段A具有以下数据:

Comment 1 by User 1 01/01/2014: Jhyap 
<br>
Comment 2 by User 2 01/05/2014: Momo kasto mitho
<br>
Comment 3 by User 3 01/05/2014: Launa k garney aba

当前在使用 <g:fieldValue bean="${Instance}" field="Field A"/>时,gsp显示字段为 Comment 1 by Saila 01/01/2014: Jhyap<br>Comment 2 by Kaila 2 01/05/2014: Momo kasto mitho<br>Comment 2 by Kaila 2 01/05/2014: Momo kasto mitho<br>
是否可以像这样在GSP中显示此字段的值:

栏位A:

由Saila发表的评论1 2014年1月1日:Jhyap
由Kaila 2发表的评论2 2014年1月5日:Momo kasto mitho
Maila 3发表的评论3 2014年1月5日:Launa k garney aba

谢谢你的时间!

最佳答案

为了避免跨站点脚本(XSS), Grails会在GSP中转义${}表达式中的所有html内容,因此可以使用

${raw(htmlString)}

有关更多信息,请参见 Cross Site Scripting (XSS) Prevention

关于grails - 如何从 Controller 设置gsp元素属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27436077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com