作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 ColdFusion 9.0.1
我正在接管一个站点,而我之前的那个人创建了大约 100 个变量并将它们放入 APPLICATION 范围内。我相信他的 100 个变量会随着每次页面加载而不断被覆盖。
基本上,他在 Application.cfc 中有这个:
APPLICTION.VariableOne = "SomeStringOne";
APPLICTION.VariableTwo = "SomeStringTwo";
APPLICTION.VariableThree = "SomeStringThree";
if (not isDefined("APPLICTION.AppInfo") or not isStruct(APPLICTION.AppInfo)) {
APPLICTION.AppInfo = structNew();
APPLICTION.AppInfo.VariableOne = "SomeStringOne";
APPLICTION.AppInfo.VariableTwo = "SomeStringTwo";
APPLICTION.AppInfo.VariableThree = "SomeStringThree";
}
最佳答案
为什么不立即将定义移到 onApplicationStart() 中?如果您需要在开发过程中重置它们,您总是可以传入一个 URL 变量来标记它以进行重置,如下所示:
<!--- in Application.cfc --->
<cffunction name="onRequestStart">
<cfif IsDefined("url.resetApp")>
<cfset ApplicationStop()>
<cfabort><!--- or, if you like, <cflocation url="index.cfm"> --->
</cfif>
</cffunction>
关于coldfusion - 如何最好地创建和存储 APPLICATION 变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8301984/
我是一名优秀的程序员,十分优秀!