使用 thymeleaf 在 noscript 中檢索彈簧模型值的語法[[${gtmUrl}]] 在腳本標簽中工作正常但不適用于 noscript有沒有不同的語法在 java 控制器中設置了 gtmUrl 屬性model.addAttribute("gtmUrl", "http://test.com");在 HTML 中,<noscript>
<iframe src="[[${gtmUrl}]]"
height="0" width="0" style="display: none; visibility: hidden"></iframe>
</noscript>
3 回答

鴻蒙傳說
TA貢獻1865條經驗 獲得超7個贊
改變:
<noscript> <iframe src="[[${gtmUrl}]]" height="0" width="0" style="display: none; visibility: hidden"></iframe> </noscript>
到:
<noscript> <iframe th:src="${gtmUrl}" height="0" width="0" style="display: none; visibility: hidden"></iframe> </noscript>
它是如何工作的?
您可以通過 ${key} 訪問變量值。
例子
model.addAttribute("key", value);
${key}
在 HTML 中獲取價值
在 Thymeleaf 中,可以使用以下語法訪問這些模型屬性(或 Thymeleaf 術語中的上下文變量):
${attributeName}
,其中 attributeName 在我們的例子中是stream
。這是一個 Spring EL 表達式。簡而言之,Spring EL(Spring Expression Language)是一種支持在運行時查詢和操作對象圖的語言。

慕村9548890
TA貢獻1884條經驗 獲得超4個贊
嘗試使用th:src="${gtmUrl}",
<noscript> <iframe th:src="${gtmUrl}" height="0" width="0" style="display: none; visibility: hidden"></iframe> </noscript>

有只小跳蛙
TA貢獻1824條經驗 獲得超8個贊
嘗試使用此代碼
<noscript> <iframe src="[[@{gtmUrl}]]" height="0" width="0" style="display: none; visibility: hidden"></iframe> </noscript>
在這里我用@
唱歌代替$
添加回答
舉報
0/150
提交
取消