我有一个页面,它从会话变量(session.stufailedarray)将包含一些信息的数组打印到屏幕上。在页面顶部,有一个将信息导出到 Excel 的链接。当我尝试这个(在 Firefox、IE 和 Chrome 中)时,它工作正常。但是用户一直告诉我他们收到一条错误消息:“元素 stufailarray 未定义是会话”。我知道变量在那里,因为它只是将它打印到屏幕上,我可以在调试中看到它。为什么会发生这种情况,而且只是有时?
产生错误的代码:
<cfset ind=0>
<cfset anArray=arrayNew(2)>
<cfloop array="#session.stufailarray#" index="k">
<cfset ind+=1>
<cfset session.failed=find("UPDATE FAILED: ", "#k#")>
<cfset session.rrr=REFind("\d{9,9}", "#k#")>
<cfset idno=mid("#k#", REFind("\d{9,9}", "#k#"), 9)>
<cfset failed=mid("#k#", Refind("UPDATE FAILED: ", "#k#"), Len(#k#)-(Refind("UPDATE FAILED: ", "#k#")))>
<cfset anArray[ind][1]=#idno#>
<cfset anArray[ind][2]=#failed#>
</cfloop>
<!--- Set content type. --->
<cfcontent type="Application/vnd.ms-excel">
<cfheader name="Content-Disposition" value="filename=load_status.xls">
<cfoutput>
<table cols=2 border=1>
<cfloop from="1" to ="#ArrayLen(anArray)#" index="row">
<tr>
<td>#anArray[row][1]#</td>
<td>#anArray[row][2]#</td>
</tr>
</cfloop>
</table>
</cfoutput>