經與freemarker的輸出問題...Freemarker的:避免轉義字符的HTML
[#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] – Goose
請注意'[#noescape]'現已被棄用[freemarker.org/docs/ref_directive_escape.html](http://freemarker.org/docs/ref_directive_escape.html )。從Freemaker ** 2.3.24 **開始,在城裏看到新的孩子們:[freemarker.org/docs/dgui_misc_autoescaping.html](http://freemarker.org/docs/dgui_misc_autoescaping.html) –