Application.cfc内置变量

Phi*_*enn 3 coldfusion application.cfc coldfusion-9

在ColdFusion版本9中,我在Index.cfm中有以下内容:

<cfdump var="#Application#">
Run Code Online (Sandbox Code Playgroud)

但我唯一得到的是带有applicationname的结构 - 没有其他变量,如rootPath,mappings或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">
Run Code Online (Sandbox Code Playgroud)

Ray*_*den 5

那是因为这些设置不在应用范围内.您将应用程序设置与应用程序值混淆.如果您希望它们在Application范围内可用,您只需在onApplicationStart()中进行设置即可.您也可以通过此范围查看它们,因此您可以在那里复制值.