嗨我有一個名爲「tsks_Session」,執行會話任務的CFC /組件。在這個cfc/init()函數中,創建了一個包含應用程序中所需的所有變量的結構。一些變量是數組類型。結構'與'類型''陣列'的SESSION變量
<cfcomponent >
<cffunction name="init">
<cfargument name="structKey" >
<cflock timeout="35" >
<cfset SESSION = structNew() >
<cfset SESSION.bar_code = "" >
<cfset SESSION.price = "" >
<cfset SESSION.pub_date = "01/01/1900" >
<cfset SESSION.author = ArrayNew() >
<cfset SESSION.title = ArrayNew() >
<cfset SESSION.[bar_code_subj_pric] = structNew() > <!--- key = concatanation of
bar_code and price --->
<cfset SESSION.[bar_code_subj_pric].author = ArrayNew() >
<cfset SESSION.[bar_code_subj_pric].title = ArrayNew() >
</cflock>
</cffunction>
<!---getter--->
<cffunction name="getAuthor" returntype="array" access="public" output="false">
<cfscript>return SESSION.author; </cfscript>
</cffunction>
<!---setter:adding the Array/"author" to the structue/"SESSION.[bar_code_subj_pric]" --->
<cffunction name="setAuthor" retuntype="void" access="public" output="false">
<cfargument name="bar_code_subj_pric" type="string" required="true">
<cfargument name="author" type="array" required="true">
<cfset var q = "" >
<cfparam name="author" default="" >
<cfloop index="i" from="1" to="arrayLen(SESSION.[bar_code_subj_pric].author)">
<cfset SESSION.author = ArrayAppend(SESSION.[bar_code_subj_pric].author,"#arguments.author#")>
</cfloop>
</cffunction>
<!---getter.title--->
<cffunction name="gettitle" returntype="array" access="public" output="false">
<cfscript>return SESSION.title; </cfscript>
</cffunction>
<!---setter:adding the Array/"title" to the structue/"SESSION.[bar_code_subj_pric]" --->
<cffunction name="settitle" retuntype="void" access="public" output="false">
<cfargument name="bar_code_subj_pric" type="string" required="true">
<cfargument name="title" type="array" required="true">
<cfset var q = "" >
<cfparam name="title" default="" >
<cfloop index="i" from="1" to="arrayLen(SESSION.[bar_code_subj_pric].title)">
<cfset SESSION.title = ArrayAppend(SESSION.[bar_code_subj_pric].title,"#arguments.title#")>
</cfloop>
</cffunction>
</cfcomponent>
一個顯示頁上的1)中,具有instanitiated CFC中, 我創建了一個STR稱爲
<cfset str[expld133] =structnew()>
當我輸出的功能setAuthor( 「expld133」,凱利)/的setTitle(「expld133 「,33.22),我得到"The value that i am not passing an array type".
請告訴我什麼是錯的?
2)我可以創建一個名爲「SESSION」的結構嗎?它是否安全?
3)有沒有錯誤的方式,我將2個不同的數組(作者/標題)添加到主結構「SESSION。[bar_code_subj_pric]」?