Grails TagLib输出错误的编码
我使用的是一个TagLib,但它表现出一种奇怪的行为,而不是像Grails TagLib输出错误的编码,grails,taglib,html-encode,Grails,Taglib,Html Encode,我使用的是一个TagLib,但它表现出一种奇怪的行为,而不是像这样的输出字符删除这行: 静态defaultEncodeAs=[taglib:'html'] 然后再试一次。您也可以告诉它以文本形式发送(不需要编码) 改变 到 class LoginTagLib { static defaultEncodeAs = [taglib:'html'] //static encodeAsForTags = [tagName: [taglib:'html'], otherTagName: [taglib:'
这样的输出字符删除这行:
静态defaultEncodeAs=[taglib:'html']
然后再试一次。您也可以告诉它以文本形式发送(不需要编码)
改变
到
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"}}]"""
}
}
<g:loginControl />
Hello Jane Smith[<a href="/Blogito/user/logout">Logout</a>]
<div id="loginHeader">
Hello Jane Smith[<a href="/Blogito/user/logout">Logout</a>]
</div>
static defaultEncodeAs = [taglib:'html']
static defaultEncodeAs = [taglib:'text']