1
我有一個GSP如下:逃離小腳本輸出2.3.0
<%=model.something%>
而在Config.groovy中,我有:
grails {
views {
gsp {
encoding = 'UTF-8'
htmlcodec = 'xml' // use xml escaping instead of HTML4 escaping
codecs {
expression = 'html' // escapes values inside null
scriptlet = 'html' // escapes output from scriptlets in GSPs
taglib = 'html' // escapes output from taglibs
staticparts = 'none' // escapes output from static template parts
}
}
// escapes all not-encoded output at final stage of outputting
filteringCodecForContentType {
//'text/html' = 'html'
}
}
}
但是,當我設置model.something = 「<腳本>警報('東西')< /腳本>」在控制器中並呈現視圖,我得到警報框。
如果我將它改爲使用$ {model.something}來代替,它似乎會正確地轉義。但我希望保持安全並確保scriptlet輸出也被編碼。我需要配置中的其他東西來實現它嗎?