2012-10-25 112 views
0

我想第一次使用映射,我有一些問題。在我CFadmin我創建了一個映射這是這樣的:Coldfusion映射cfinclude

邏輯路徑:

/email_sender

目錄路徑:

E:\sites\Example.Com\cf_modules\autoresponders\Emails\emailLists

我試圖從.cfc訪問包含文件。在我的cfc裏面,我有一個包含在同一個文件夾中的文件,它工作的很好,但是包含文件正在根據我傳遞的信息綁定到另一個包含文件。

組件中的包含文件在其中包含此代碼。

<cfmail from="#emailData.sender#" to="#surveymain.email#" subject="#subject#" type="HTML" > 
    <cfinclude template="#emailData.includePath#" > 
</cfmail>  

只是爲了更清楚,這是我的總的文件系統:

access.cfm -> some.cfc -> include_1 (works) -> include_2 (issue with the path)

我有一個try/catch哪些電子郵件我的錯誤,它位於include_1內。

如何使用我創建的映射最終能夠訪問我的包含文件?

請注意,emailLists之後,我有動態文件夾,根據我試圖發送電子郵件的客戶端而有所不同。因此該路徑的最終結果將是:

E:\sites\Example.Com\cf_modules\autoresponders\Emails\emailLists\client_A\email_template.cfm 

我試圖用我的映射做這個 <cfinclude template="/email_sender/#emailData.includePath#" >

這給了我這個錯誤:

The path to the CFC must be specified as a full path, or as a relative path from the current template, without the use of mappings.

而且,我試着包括cfinclude中的完整路徑也導致了以下錯誤:

Note: If you wish to use an absolute template path (for example, >template="/mypath/index.cfm") with CFINCLUDE, you must create a mapping for the path using the ColdFusion Administrator. Or, you can use per-application settings to specify mappings specific to this application by specifying a mappings struct to THIS.mappings in Application.cfc.
Using relative paths (for example, template="index.cfm" or template="../index.cfm") does not require the creation of any special mappings. It is therefore recommended that you use relative paths with CFINCLUDE whenever possible.

任何幫助/建議將不勝感激

編輯: 重新啓動該工作的版本是這樣的一個服務器後: <cfinclude template="/email_sender/#emailData.includePath#" >

感謝那些誰回答。

+1

自從您添加映射後,您是否重新啓動了服務器? – John

+0

當然它必須是這....感謝提醒我,現在它工作正常.. – Geo

回答

3

有些問題,而不是一些答案。

  1. 您是否在CFAdmin或Application.cfc中設置了映射?
  2. 如果你運行下面的代碼,你會得到什麼?

    #expandPath( 「/ EMAIL_SENDER」)#

  3. 什麼是#emailData.includePath#價值?

  4. 這是什麼值:#expandPath("/email_sender#emailData.includePath#")#
  5. 您能否向我們提供錯誤消息的確切文本,而不是模糊地描述它們。
  6. #fileExists(expandPath("/email_sender#emailData.includePath#"))#的值是多少?

如果您可以更新這些信息你的問題,你會發現無論你要​​去哪裏錯了,或者我們可以幫助制定出這個故事是什麼

+0

我很感謝你的回答我的朋友,但不幸的是(或幸運)我唯一的錯誤是,我忘了重新啓動我的應用程序服務器。 – Geo

+2

笑了起來。好吧。通常不需要重新啓動映射創建/更改服務器,所以這有點奇怪。 –

0

像這樣的事情發生在我身上一次之前。基本上我們編輯了xml文件,而不是使用管理界面。直到我們的系統管理員重新啓動服務器,直到我們意識到爲什麼沒有進行映射。那麼你是否添加了映射後重新啓動了服務器?

+0

是的,這是我的問題。重新啓動服務器後,一切正常。我希望這篇文章能夠幫助將來的人做出同樣的錯誤 – Geo

+0

我認爲這裏的*錯誤與配置文件混淆,而不是通過Application.cfc或CFAdmin UI(甚至CFAdmin API!)來完成。仍然:我猜你現在在工作,所以這是主要的。 –

+0

@AdamCameron我通過CFAdmin完成了它,但我仍然需要重新啓動CF應用程序服務 – Geo

相關問題