2011-02-28 64 views
0

我有一个反复返回以下错误的自定义的ColdFusion错误页面,往往后的页面已经被扫描的一个机器人:ColdFusion错误:“元素REMOTEADDRESS在错误中未定义。”我如何解决它?

元REMOTEADDRESS是错误的,不确定的。 ###(页码)发生错误。

我不知道为什么它会返回这个未定义的元素错误,或者如果有办法解决它,除了删除#error.remoteAddress#代码。

我的代码如下所示:

<cferror type="REQUEST" template="error.cfm" mailto="[email protected]"> 
<cfoutput> 
<ul> 
    <li><strong>Your Location:</strong> #error.remoteAddress# 
    <li><strong>Your Browser:</strong> #error.browser# 
    <li><strong>Date and Time the Error Occurred:</strong> #error.dateTime# 
    <li><strong>Page You Came From:</strong> #error.HTTPReferer# 
    <li><strong>Error Diagnostics</strong>: 
    <p>#error.diagnostics#</p> 
</ul> 
</cfoutput> 

回答

2

没有在这里完全理解整个逻辑,如果你希望能够安全地测试,看是否有变,或结构的成员试图对其进行评估之前就存在,你可以这样做

<cfif isDefined("error") AND structKeyExists(error, "remoteAddress")>#error.remoteAddress#</cfif> 
2

remoteAddress仅在request and exception type errors可用,因此显示错误变量之前检查错误类型。

<cfif ListFind("request,exception",error.type)> 
    <li><strong>Your Location:</strong> #error.remoteAddress#</li> 
</cfif> 

你也可以检查错误类型不是“验证”,但我喜欢成为一种积极的人。

ps。请注意我关闭了您的清单项目。 ;)

3

您应该使用爱德华的解决方案来验证变量的存在,或cfparam的值,以便它总是存在:

<cfparam name="Error.remoteAddress" default="No Remote Address" /> 
相关问题