該文檔說它可以在Administrator ColdFusion映射頁面中指定的目錄中工作。您是否嘗試過在ColdFusion管理員中設置映射以查看該映射是否首先運行?如果可行,但在application.cfc中爲每個應用程序設置的this.mappings不起作用,那麼可能它是一個錯誤?!?
編輯: 我測試了亞當的建議,使用expandPath()函數,但是這也不起作用,因爲標籤庫屬性必須包含一個恆定值。它不能包含變量或函數。除非您使用ColdFusion管理器中的映射集,否則它不起作用。我使用這個application.cfc嘗試了下面的測試。
<cfcomponent>
<cfset this.name = "TestApp" />
<cfset this.loginStorage = "session" />
<cfset this.sessionManagement = true />
<cfset this.setClientCookies = true />
<cfset this.setDomainCookies = false />
<cfset this.sessionTimeOut = CreateTimeSpan(0,12,0,0) />
<cfset this.applicationTimeOut = CreateTimeSpan(1,0,0,0) />
<cfset this.mappings['/CT'] = "C:\apache\htdocs\myProjects\Project1\CustomTags"/>
</cfcomponent>
而這在一個ColdFusion模板:
<cfimport prefix="tag" taglib="#expandpath('/CT')#">
拋出錯誤:
This expression must have a constant value.
<cfset CT = expandpath('/CT')/>
<cfimport prefix="tag" taglib="#CT#">
拋出錯誤:
This expression must have a constant value.
This.mappings需要位於Application.cfc的頂部,並且cfimport需要位於頁面上。 我已經用cfinclude成功地使用了This.mappings,但沒有使用cfimport。 – 2009-06-24 15:17:01