railo application.cfc this.mappings不工作 [英] railo application.cfc this.mappings not working

查看:224
本文介绍了railo application.cfc this.mappings不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用最新版本的railo,我试图获得每个应用程序的映射工作。这是我在做什么:

i am using the latest version of railo, and am trying to get the per-application mappings to work. this is what i am doing:

<cfcomponent name="MyApp">
    <cfset THIS.Name = "MyApp">
    <cfset THIS.Mappings["/myapp"] = ExpandPath(".")>
</cfcomponent>

所以,我试图能够通过myapp。*映射访问这个应用程序文件夹中的组件而不是必须到rootapp.myapp。*(从我理解,这个组件设置应该然后工作。

so, i am trying to be able to access components within this application folder through a myapp.* mappings rather than having to to rootapp.myapp.* (from what i understand, this component setup should then work.

然而,我的组件不能通过此映射访问,当我在我的代码中对应用程序变量执行cfdump时,会显示applicationname设置为MyApp,但没有显示映射。

however, my components cannot be accessed by this mapping, and when i do a cfdump on the application variable in my code, it will show that the "applicationname" is set to "MyApp", but nothing shows for the mappings.

railo不支持这些映射,或者我做错了什么?

does railo not support these mappings, or am i doing something wrong?

编辑:

我得到的错误:

invalid component definition, can't find myapp.data.MyObject

应该已经创建了 myapp 映射, > MyObject 确实存在。这里是我的结构:

the myapp mapping should have been made, and the MyObject does exist. here is my structure:

/rootfolder/myapp/Application.cfc
/rootfolder/myapp/data/MyObject.cfc
/rootfolder/myapp/pages/MyPage.cfm

简单来说,MyPage.cfm依赖于映射来容易地访问MyObject组件。

in short, "MyPage.cfm" relies on the mapping to easily access the "MyObject" component. the Application.cfc should be loaded as the cfml processor should start moving up directories until it finds one.

推荐答案

应用程序应该加载Application.cfc

Your syntax is OK, I've just did the same for application deep in directories tree and it works fine.


你的语法是OK的,我只是在应用程序深层目录树中做的相同。我的组件无法通过此映射访问,

however, my components cannot be accessed by this mapping,

什么是确切的错误? 无效的组件定义,找不到myapp.xyz?

What is exact error? "invalid component definition, can't find myapp.xyz"?

您的cfm和cfc是否在同一目录中? (这基本上是你想要做的)

Are your cfm and cfc in the same directory? (this is basically what you are trying to do)


当我在我的代码中的应用程序变量cfdump时, applicationname设置为MyApp,但没有显示映射。

and when i do a cfdump on the application variable in my code, it will show that the "applicationname" is set to "MyApp", but nothing shows for the mappings.

你不会看到这个信息,应用范围。只有选项是像平常一样使用Application.cfc cfc。

You wont see this info by dumping the application scope. Only option is to use Application.cfc as usual cfc.

<cfset app = CreateObject("component",  "application") />
<cfdump var="#app#">

编辑。这里有两个解决方案。

EDIT. You have two solutions here.

定义这样的映射,因此将为Application.cfc计算路径:

Define mapping like this, so path will be calculated for Application.cfc:

<cfset this.mappings["/myapp2"] = getDirectoryFromPath(getCurrentTemplatePath())>

或更改组件路径,如下所示:

Or change component path like this:

<cfset MyObject = CreateObject("component",  "myapp.data.MyObject") />

问题在于 ExpandPath返回的路径之间的差异 getCurrentTemplatePath()

这篇关于railo application.cfc this.mappings不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆