例如,我有以下代码:
<cfhttp url="FileURL" method="get" result="HTTPResult" timeout="5" />
我想这样做:
<cfoutput>
#HTTPResult.ResponseHeader.content-type#
</cfoutput>
但是,ColdFusion 会将破折号 -
视为运算符,并尝试从“type”中减去变量“HTTPResult.ResponseHeader.content”,但两者都不存在。有没有直接的方法来访问“内容类型”变量,或者我是否需要跳过一些麻烦才能从 header 变量中获取它?
最佳答案
HTTPResult.ResponseHeader["content-type"]
关于variables - 如何访问 ColdFusion 中包含特殊字符的变量名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6312226/