【发布时间】:2023-11-20 21:23:01
【问题描述】:
freemarker 输出有问题...
[#assign optionsHTML = ""]
[#list data as item]
[#assign optionsHTML = optionsHTML + '<option value="' + item.value +'>'+ item.label + '</option>' /]
[/#list]
所以,如果我这样做了
<select>
${iptionsHTML}
</select>
otions 的输出得到 html 实体而不是实际的 html....所以
<option value=" .....
即使我这样做了
[#assign optionsHTML = ""]
[#list data as item]
[#noescape]
[#assign optionsHTML = optionsHTML + '<option value="' + item.value +'>'+ item.label + '</option>' /]
[/#noescape]
[/#list]
试过了
<select>
${iptionsHTML?html}
</select>
但更糟糕的是:(
【问题讨论】:
-
你试过在输出周围放置 noescape 吗? [#noescape]${optionsHTML}[/#noescape]
-
请注意,
[#noescape]现在已弃用 freemarker.org/docs/ref_directive_escape.html。看看 Freemaker 2.3.24 以来镇上的新孩子:freemarker.org/docs/dgui_misc_autoescaping.html
标签: freemarker html-escape-characters