我有一個網址mysite.com/?action=admin:content.form
。在這裏,我檢查表單是否可用:不能將字符串轉換爲布爾值?
<div class="widget-body">
<div class="widget-toolbox">
<div class="btn-toolbar">
<div class="btn-group">
<cfif ListLast(rc.action,".")>
<a href="##" class="#local.btn#">
<i class="icon-plus"></i>
Add More
</a>
</cfif>
</div>
</div>
</div>
如果存在,那麼我將顯示一個按鈕。如果不是,則什麼也不顯示。我已經嘗試了以上,但得到了錯誤Can't cast String [form] to a boolean
。任何人都可以幫我弄清楚出了什麼問題?由於
然後'ListLast'將返回文字字符串'「form」'。顯然這不是一個布爾值。所以你需要一個不同類型的比較(或者可能是一個不同的表達式)。一切取決於你的應用程序。例如,您試圖確定最後一個元素是否等於「form」,請使用簡單字符串比較,例如'' –
Leigh