文本模板模式用於解決thymeleaf模板中輸出js的需求

需要從後臺模型變量中存儲的 js 腳本輸出到頁面上,常見的語法都解決不了,後來在官網提供的Using Thymeleaf 的pdf教程看到:

13 Textual template modes

Three of the Thymeleaf template modes are considered textual: TEXT , JAVASCRIPT and CSS . This differentiates them
from the markup template modes: HTML and XML .

a perfectly valid template for a text email.

Dear [(${name})],

Please find attached the results of the report you requested
with name "[(${report.name})]".

Sincerely,
  The Reporter.

終於找到了 [(${name})] 這個語法,可以不轉義直接輸出模型中的值,js的內容也能原樣輸出

這樣,終於能解決 後臺埋碼的問題了

本文內容到此結束。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章