【问题标题】:Grails 2.4.3 scriptlet blocks didn't parse html tagsGrails 2.4.3 scriptlet 块没有解析 html 标签
【发布时间】:2014-09-25 07:16:40
【问题描述】:

我正在尝试将我的 grails 应用程序从 2.3.0 升级到 2.4.3。

我尝试使用scriptlet块来渲染一个html代码,代码如下所示

<%="<a href=\"http://foo.com\">foo</a>"%>

实际上,它应该呈现为 href 链接,但在 2.4.3 中它只是将代码呈现为字符串,有人有同样的问题并有什么建议吗?此代码在 2.3.0 但 2.4.3 中运行良好。

【问题讨论】:

  • 你的Config.vgroovy中grails.views.default.codec的值是多少?
  • grails.views.default.codec="html"

标签: html grails gsp scriptlet


【解决方案1】:

问题是您的默认编解码器是 HTML 转义字符串中的实体。如果您需要原始字符串,请使用.encodeAsRaw()

<%="<a href=\"http://foo.com\">foo</a>".encodeAsRaw()%>

【讨论】:

    猜你喜欢
    • 2015-10-06
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 2012-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-01
    相关资源
    最近更新 更多