我正在关注Ben Nadel的tutorial,我在浏览器网络/ XHR中收到以下错误。
无法将复杂对象类型转换为简单值
我认为问题出现在CFLoop标签中,但我不确定应该修改什么来解决错误。
<!---
Get the content as a byte array (by converting it to binary,
we can echo back the appropriate length as well as use it in
the binary response stream.
--->
<cfset binResponse = ToBinary(ToBase64( objRequest.FileContent )) />
<!--- Echo back the response code. --->
<cfheader statuscode="#Val( objRequest.StatusCode )#" statustext="#ListRest( objRequest.StatusCode, ' ' )#" />
<!--- Echo back response legnth. --->
<cfheader name="content-length" value="#ArrayLen( binResponse )#" />
<!--- Echo back all response heaers. --->
<cfloop item="strKey" collection="#objRequest.ResponseHeader#">
<!--- Check to see if this header is a simple value. --->
<cfif IsSimpleValue( objRequest.ResponseHeader[ strKey ] )>
<!--- Echo back header value. --->
<cfheader name="#strKey#" value="#objRequest.ResponseHeader[ strKey ]#" />
</cfif>
</cfloop>
<!---
Echo back content with the appropriate mime type. By using
the Variable attribute, we will make sure that the content
stream is reset and ONLY the given response will be returned.
--->
<cfcontent type="#objRequest.MimeType#" variable="#binResponse#" />
答案 0 :(得分:0)
我注释掉每行代码,直到我发现问题行代码是cfheader。事实证明,我甚至不需要整个cfloop代码块。本教程的作者可能对此代码块有其他用途,但对于我所做的事情,它没有它可以正常工作。非常感谢那些试图提供帮助的人。
<cfheader name="#strKey#" value="#objRequest.ResponseHeader[ strKey ]#" />