针对不同应用的不同位置的 Coldfusion 映射
Coldfusion Mappings For Different Locations For Different Applications
我目前在同一台服务器上有多个应用程序。这些应用程序位于彼此不同的文件夹中。
在应用程序中,我们动态创建一个名为 "custom" 的映射,它需要为每个应用程序指向适当的 "custom" 文件夹。
例如,取以下三个应用程序及其路径:
app1 c:\inetpub\app1\custom
app2 c:\inetpub\app2\custom
app3 c:\inetpub\app3\custom
我用来为一个应用程序执行此操作(在 OnApplicationStart 中调用)的代码是:
<cffunction name="CreateAppMappings" output="no" returntype="void">
<cfargument name="absolutePath" required="yes" />
<cfscript>
mappingCustom = "/custom";
serviceFactory = createObject("java","coldfusion.server.ServiceFactory");
mappings = serviceFactory.runtimeService.getMappings();
mappings["/custom"] = "#arguments.absolutePath#\wwwroot";
</cfscript>
<cfreturn />
</cffunction>
问题是,对于一个应用程序,这是可行的。但对于多个应用程序,它会自然地被覆盖,因为映射名称是相同的。
为了让我们对所有应用使用相同的代码库,每个应用的映射名称应该一致 ("custom")。
那么我们如何实现呢?
我能想到的唯一方法是 运行 每个应用程序作为一个单独的实例,使用 CFAdmin 中的实例管理器。
那是我唯一的选择吗?或者还有其他我可能不知道的事情吗?
我是运行CF2018.
谢谢
@Paolo Broccardo,根据@RRK 建议,您可以在 Application.cfc 文件中进行设置,如下所示
component output="false" {
this.name ='Your Apps name';
this.sessionManagement = true;
this.sessiontimeout = createTimeSpan(0,1,0,0);
this.root = getDirectoryFromPath( getCurrentTemplatePath() );
this.mappings[ '/custom' ] = "#this.root#/folder1" ;
.........
.........
}
这里的根目录是我的应用程序的根目录,/custom 用于映射您的自定义目录详细信息。您可以像 app.cfc 文件本身中的数字一样设置它。
我目前在同一台服务器上有多个应用程序。这些应用程序位于彼此不同的文件夹中。 在应用程序中,我们动态创建一个名为 "custom" 的映射,它需要为每个应用程序指向适当的 "custom" 文件夹。
例如,取以下三个应用程序及其路径:
app1 c:\inetpub\app1\custom
app2 c:\inetpub\app2\custom
app3 c:\inetpub\app3\custom
我用来为一个应用程序执行此操作(在 OnApplicationStart 中调用)的代码是:
<cffunction name="CreateAppMappings" output="no" returntype="void">
<cfargument name="absolutePath" required="yes" />
<cfscript>
mappingCustom = "/custom";
serviceFactory = createObject("java","coldfusion.server.ServiceFactory");
mappings = serviceFactory.runtimeService.getMappings();
mappings["/custom"] = "#arguments.absolutePath#\wwwroot";
</cfscript>
<cfreturn />
</cffunction>
问题是,对于一个应用程序,这是可行的。但对于多个应用程序,它会自然地被覆盖,因为映射名称是相同的。
为了让我们对所有应用使用相同的代码库,每个应用的映射名称应该一致 ("custom")。 那么我们如何实现呢?
我能想到的唯一方法是 运行 每个应用程序作为一个单独的实例,使用 CFAdmin 中的实例管理器。 那是我唯一的选择吗?或者还有其他我可能不知道的事情吗?
我是运行CF2018.
谢谢
@Paolo Broccardo,根据@RRK 建议,您可以在 Application.cfc 文件中进行设置,如下所示
component output="false" {
this.name ='Your Apps name';
this.sessionManagement = true;
this.sessiontimeout = createTimeSpan(0,1,0,0);
this.root = getDirectoryFromPath( getCurrentTemplatePath() );
this.mappings[ '/custom' ] = "#this.root#/folder1" ;
.........
.........
}
这里的根目录是我的应用程序的根目录,/custom 用于映射您的自定义目录详细信息。您可以像 app.cfc 文件本身中的数字一样设置它。