我正在使用 CFM2WDDX
转换 CF11 中的数组,但出现此错误:
coldfusion.tagext.validation.WddxValidator$InvalidWddxPacketException: Invalid WDDX packet..
我在这里使用这段代码:
getFileList.cfm
<cfsetting enablecfoutputonly="Yes">
<cfset thisdir = ExpandPath(".\")>
<cfdirectory directory="#thisdir#" action="LIST" name="imagefiles" recurse="No">
<cfscript>
// get .gif|.jpg|.png files from the cfdirectory query...
numRows = imagefiles.recordcount;
imageFileArray = ArrayNew(1);
for (row = 1; row LTE numRows; row++) {
if (refindnocase("(.gif|.jpg|.png)",imagefiles.name[row]) neq 0) {
ArrayAppend(imageFileArray, imagefiles.name[row]);
}
}
</cfscript>
<cfwddx action="cfml2wddx" input=#imageFileArray# output="wddxText">
<cfoutput>#wddxText#</cfoutput>
如您所见,代码创建了一个图像名称数组,然后我通过 cfhttp 访问该数组以执行我需要的操作。我在 CF9 服务器上有完全相同的代码和完全相同的目录内容,并且可以正常工作,但在 CF11 中我遇到格式错误。这个特性在 CF11 中有什么变化吗?
这是我用来访问上面代码的代码:
<cfhttp url="http://example.com/images/ClientLogos/getFileList.cfm" method="GET" timeout="10" throwonerror="Yes">
<cfwddx action="WDDX2CFML" input="#trim(cfhttp.filecontent)#" output="imageArray" validate="true">
<cfreturn imageArray>
getFileList.cfm
与图像位于同一目录中,因此它在被调用的本地服务器上执行。 (这就是为什么我认为 CF11 可能是问题所在)
CF9 的部分输出:
以及 CF11 的部分输出:
来自 CF 11 的 CFHTTP.Header:
HTTP/1.1 200 OK Content-Type: text/html;charset=UTF-8 Server: Microsoft-IIS/8.0 X-Powered-By: ASP.NET Access-Control-Allow-Origin: * Date: Tue, 31 Mar 2015 18:50:35 GMT Connection: close Content-Length: 10807
来自 CF 9 的 CFHTTP.Header:
HTTP/1.1 200 OK Content-Type: text/html; charset=UTF-8 Vary: Accept-Encoding Server: Microsoft-IIS/7.5 X-Powered-By: ASP.NET Date: Tue, 31 Mar 2015 18:51:20 GMT Connection: close
最佳答案
我不确定是什么导致了这种行为,但我现在找到了一个中间立场。我没有通过 cfhttp 调用 getFileList.cfm,而是将代码从 getFileList.cfm 直接移到我的函数中,一切正常。以该文件开头的原因是允许我访问我不再需要/不再使用的不同服务器上的外部图像存储库。无论哪种方式,这实际上可能是一个 CF11 错误,因此我们将在未来看到......
关于coldfusion - CFML2WDDX 错误 ColdFusion 11,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29374012/