Application.cfc 内置变量
在 ColdFusion 版本 9 中,我在 Index.cfm 中有以下内容:
<cfdump var="#Application#">
但我得到的唯一结果是带有应用程序名称的结构 - 没有其他变量,如 rootPath、映射或 customTagPath。
这是我在 Application.cfc 中的内容:
<cfcomponent output="false">
<cfset this.name = left("App_#hash(getCurrentTemplatePath())#",64)>
<cfset this.applicationTimeout = createTimeSpan(0,8,0,0)>
<cfset this.sessionManagement=True>
<cfset this.loginStorage = "session">
<cfset this.clientManagement = False>
<cfset this.setClientCookies = True>
<cfset this.setDomainCookies = False>
<cfset this.scriptProtect = "all">
<cfset this.rootPath = getDirectoryFromPath(getCurrentTemplatePath())>
<cfset this.mappings = this.rootPath>
<cfset this.customTagPaths = "#this.rootPath#Components">
In ColdFusion version 9, I have the following in Index.cfm:
<cfdump var="#Application#">
But the only thing I'm getting back is a struct with the applicationname - no other variables like rootPath, mappings or customTagPath.
Here's what I have in Application.cfc:
<cfcomponent output="false">
<cfset this.name = left("App_#hash(getCurrentTemplatePath())#",64)>
<cfset this.applicationTimeout = createTimeSpan(0,8,0,0)>
<cfset this.sessionManagement=True>
<cfset this.loginStorage = "session">
<cfset this.clientManagement = False>
<cfset this.setClientCookies = True>
<cfset this.setDomainCookies = False>
<cfset this.scriptProtect = "all">
<cfset this.rootPath = getDirectoryFromPath(getCurrentTemplatePath())>
<cfset this.mappings = this.rootPath>
<cfset this.customTagPaths = "#this.rootPath#Components">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那是因为这些设置不在应用程序范围内。您混淆了应用程序设置与应用程序值。如果您希望它们在应用程序范围内可用,您只需在 onApplicationStart() 中设置它们即可。当然,您也可以通过 This 范围查看它们,因此您可以将值复制到那里。
That's because those settings aren't in the Application Scope. You are confusing Application settings versus Application values. If you want them available in the Application scope, you can simply set them up in your onApplicationStart(). You can also see them via the This scope of course, so you copy the values there.