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

查看:16
本文介绍了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 时,它会显示应用程序名称"设置为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?

这是我得到的确切错误:

this is the exact error that i am getting:

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"组件.Application.cfc 应该被加载,因为 cfml 处理器应该开始向上移动目录,直到找到一个.

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.

推荐答案

你的语法没问题,我刚刚对目录树深处的应用程序做了同样的事情,它工作正常.

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

但是,此映射无法访问我的组件,

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 时,它会显示应用程序名称"设置为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.

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") />

问题在于 ExpandPathgetCurrentTemplatePath() 返回的路径之间存在差异.

Problem is in differences between paths returned by ExpandPath and getCurrentTemplatePath().

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

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