2012-10-25 48 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