作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
谁能告诉我是什么问题?我尝试运行一些 .cfm 文件,但除了 cfcomponent 之外,它不会触发 cffunction 的任何影响?我错过了什么吗?谁能给我解释一下?
<cfcomponent>
<cfset THIS.Name = "formdemo">
<cfset THIS.SessionManagement = true>
<cfset This.Sessiontimeout="#createtimespan(0,0,20,0)#">
<cfset This.applicationtimeout="#createtimespan(5,0,0,0)#">
--Entered cfcomponent--
<cffunction name="onApplicationStart" returnType="boolean" output="false">
--Entered Application Start--
<cfset application.portfolioUploadRoot = "ram:///portfoliouploads">
<cfif not directoryExists(application.portfolioUploadRoot)>
<cfdirectory action="create" directory="#application.portfolioUploadRoot#">
</cfif>
<cfreturn true>
</cffunction>
<cffunction name="onSessionStart" returnType="void" output="false">
--Entered Session Start--
<cfset session.myuploadroot = application.portfolioUploadRoot & "/" & replace(createUUID(), "-", "_", "all")>
<cfif not directoryExists(session.myuploadroot)>
<cfdirectory action="create" directory="#session.myuploadroot#">
</cfif>
</cffunction>
<cffunction name="onApplicationEnd" returnType="void" output="false">
--Entered Application End--
<cfargument name="applicationScope" required="true">
<cfif directoryExists(arguments.applicationScope.portfolioUploadRoot)>
<cfdirectory action="delete" recurse="true" directory="#arguments.applicationScope.portfolioUploadRoot#">
</cfif>
</cffunction>
<cffunction name="onSessionEnd" returnType="void" output="false">
--Entered Session End--
<cfargument name="sessionScope" type="struct" required="true">
<cfargument name="appScope" type="struct" required="false">
<cfif directoryExists(arguments.sessionScope.myuploadroot)>
<cfdirectory action="delete" recurse="true" directory="#arguments.sessionScope.myuploadroot#">
</cfif>
</cffunction>
</cfcomponent>
<cfparam name="form.textname" default="">
<cfparam name="form.textemail" default="">
<cfparam name="form.docattach" default="">
<cfif structKeyExists(form, "Submit")>
<cfset form.textname = trim(htmlEditFormat(form.textname))>
<cfset form.textemail = trim(htmlEditFormat(form.textemail))>
<cflocation url="formcomplete.cfm" addToken="false">
</cfif>
<!DOCTYPE html>
<html>
<head>
...
</head>
<body>
<form method="post" enctype="multipart/form-data">
<cfoutput>
<input id="textname" name="textname" type="text" class="input-large" required="" value="#form.textname#">
<input id="textemail" name="textemail" type="text" class="input-large" required="" value="#form.textemail#">
</cfoutput>
</form>
</body>
</html>
最佳答案
它正在做它应该做的。
onApplicationStart -- Runs when ColdFusion receives the first request for a page in the application.
For this, to easily see this, you can try changing the name of the application, then
visit a page within.
onSessionStart -- Only run upon the first visit within the session. If you wait til after the
timeout and then come back, you'll see this. Changing the application name will should also
retrigger this.
onSessionEnd -- Run when the session ends. It will trigger after the timeout, it's used so that
you can clean up activity. For instance, if you're using something like Application.NumberOnline.
OnSessionEnd can substract one (where onSessionStart) can add one.
onApplicationEnd -- Runs when the application timeout occurs or the server is shutting down.
<cffunction name="onApplicationEnd">
<cfargument name="ApplicationScope" required=true/>
<cflog file="#This.Name#" type="Information"
text="Application #Arguments.ApplicationScope.applicationname# Ended" >
</cffunction>
<cfscript>
ap = createObject("component","Application");
ap.onSessionEnd(session,application);
</cfscript>
<cfscript>
function foo() {
writeoutput("bar");
}
</cfscript>
<cfoutput>#foo()#</cfoutput>
之前不会做任何事情.
关于coldfusion - application.cfc 不会触发任何默认的 cffunction?冷聚变,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27540358/
我是一名优秀的程序员,十分优秀!