【发布时间】:2016-02-08 20:20:43
【问题描述】:
我正在关注 Ben Nadel 的 tutorial,我在浏览器 Network/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#" />
【问题讨论】:
-
首先,从 CF Admin(调试和日志记录 > 调试输出设置)启用“启用鲁棒异常信息”。这样你就知道是哪一行实际抛出了错误。
-
第二,在第一个
cfset标签之后放一个cfabort标签,然后运行页面。继续移动cfabort标签,一次一个命令,直到出现错误。这将确定问题所在。
标签: coldfusion proxy