[英]Grails groovy code mixed in the view
嘿。 我需要做這樣的事情:
<td><g:formatDate format="yyyy-MM-dd" date="${it.conference.startDate}"/> (S) <u><g:formatDate format="yyyy-MM-dd" date="${it.conference.endDate}"/></u> (E)<br>
<%
def temp = new Date()
def temp2 = ${it.conference.startDate}
def temp3 = temp - temp2
out << temp3
%>
</td>
但由於某種原因,這不起作用,而我是 groovy 代碼中的${it.conference.startDate}
代碼不起作用。 任何幫助將不勝感激。
視圖中的內聯代碼因其糟糕的設計選擇而臭名昭著。 一般來說,您最好創建一個自定義標記庫來顯示您的日期。 這樣做的一些直接好處:
您應該能夠將現有代碼放入自定義標記庫並調用它,而無需進行任何重大更改。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.