Coldfusion mapping error

前端 未结 2 754
一整个雨季
一整个雨季 2021-01-27 09:26

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

2条回答
  •  醉话见心
    2021-01-27 10:12

    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 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

提交回复
热议问题