gpt4 book ai didi

每个应用程序映射的 Coldfusion 随机失败

转载 作者:行者123 更新时间:2023-12-03 23:31:22 24 4
gpt4 key购买 nike

在我的 application.cfc 文件中,我有以下代码:

this.mappings["/includes"] = "#expandPath('../../priv/inc/')#";

然后在一个页面上我设置了以下 CF include:

<cfinclude template="/includes/imageOptimise-thumbnail.cfm">

在提交页面的大部分时间里,imageOptimise-thumbnail 页面运行没有任何问题,但偶尔会出错,提示找不到 imageOptimise-thumbnail.cfm。如果我重新提交该页面,它很可能会起作用,但问题是,为什么有时找不到该页面?

我查看了 CF Admin,我在日志中没有看到任何表明有错误的信息,但它在失败时清楚地显示了 Coldfusion“找不到模板”错误消息。

有人有什么想法吗?

最佳答案

我认为您的问题源于用于映射的路径是相对的这一事实。

根据ColdFusion Mappings and Relative Paths中的建议,

the moral of the story is to NEVER use expandPath() to create a mapping that’s relative to the webroot.

尝试按照博客的建议使 webroot 静态化

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

然后从 webroot 导航到 /priv/inc/

关于每个应用程序映射的 Coldfusion 随机失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55100987/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com