【问题标题】:HTTP/1.1 500 Complex object types cannot be converted to simple valuesHTTP/1.1 500 复杂对象类型不能转换为简单值
【发布时间】: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


【解决方案1】:

我注释掉了每一行代码,直到我发现有问题的代码行是cfheader。事实证明,我什至不需要整个 cfloop 代码块。本教程的作者可能对这段代码有其他用途,但就我所做的而言,没有它也可以正常工作。非常感谢那些试图提供帮助的人。

<cfheader name="#strKey#" value="#objRequest.ResponseHeader[ strKey ]#" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2016-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-03
    相关资源
    最近更新 更多