gpt4 book ai didi

grails - TagLib输出错误的编码

转载 作者:行者123 更新时间:2023-12-04 13:39:14 24 4
gpt4 key购买 nike

我正在使用TagLib,但它呈现的是奇怪的行为,而不是输出字符<">,而是输出&lt;&quot;&gt;

编码:

class LoginTagLib {
static defaultEncodeAs = [taglib:'html']
//static encodeAsForTags = [tagName: [taglib:'html'], otherTagName: [taglib:'none']]
def loginControl =
{
if(session.user)
{
out << "Hello ${session.user.name}"
out << """[${link(action:"logout", controller:"user"){"Logout"}}]"""
}
else
{
out << """[${link(action:"login", controller:"user"){"Login"}}]"""
}
}

}

在.gsp中
<g:loginControl />

当我打开页面时,我有:
Hello Jane Smith[<a href="/Blogito/user/logout">Logout</a>] 

但是页面的源代码是:
<div id="loginHeader">
Hello Jane Smith[&lt;a href=&quot;/Blogito/user/logout&quot;&gt;Logout&lt;/a&gt;]
</div>

我已经尝试使用 .encodeAsHTML()decodeHTML.replace('&gt;', '<'),但到目前为止没有任何效果

最佳答案

删除此行:

静态defaultEncodeAs = [taglib:'html']

然后再试一次。

关于grails - TagLib输出错误的编码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24640755/

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