Coldfusion mapping error

你离开我真会死。 提交于 2019-12-02 12:26:31

CFINCLUDE uses relative paths in relation to the file where the cfinclude is, so if want to include a file in another directory, 1. it has to be inside your wwwroot (or the root directory, or subdirectories) of your site, 2. you can go to other directories by doing ... hope this helps a little bit. If you want to include a file that is outside of your wwwroot, then you'll need to map that directory in Coldfusion Administrator using the same syntax above when you do include it.

To add a mapping, open your coldfusion administrator.

Server Settings > Mappings

There are 2 paths. Logical and Directory.

Logical can be anything you want, and directory is where it maps to. eg. you might have a folder below your web root which stores email templates mapped as:

logical path: /emails
directory path: /var/www/mycfapp/content/includes/emails

You can <cfinclude template="/emails/forgotPass"> from any cf template and the mapping would get picked up.

You can use the mappings for new object creation too. Lets pretend forgotPass is a cfc.

fp = new emails.forgotPass();

// if you have funky characters in there, eg dash, just quote it.
fp = new "emails.forgot-pass"();

Mappings also work when extending cfcs. With one small exception. No leading slash.

component extends="emails/forgotPass" {
    // ...
}

Im pretty sure mappings are detected first, so if you have a folder with the same name it might not get picked up.

In cf9 you can also specify your mappings in your Application.cfc, instead of coldfusion administrator, which affects all applications on your server. eg.

this.mappings["/emails"] = "/var/www/mycfapp/content/includes/emails";

You'll need to tick the Enable Per App Settings option on the cfadmin Settings page.

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0b63c-7fd5.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!