以下代码适用于Adobe ColdFusion 9.01+,但不适用于Railo 4.1
此外,这只会在Post
此代码在setupRequest()
application.cfc
内调用
<cfthread name="threadA" action="run">
<cftry>
<cfquery>
INSERT
INTO dbo.Traffic (Circuit, Fuseaction, IP_hash)
VALUES (<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#listfirst(variables.rc.fuseaction, '.')#">,
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#listlast(variables.rc.fuseaction, '.')#">,
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#cgi.remote_addr#">
)
</cfquery>
<cfcatch />
</cftry>
</cfthread>
错误
java.lang.NullPointerException at railo.runtime.net.http.HttpUtil.cloneParameters(HttpUtil.java:66):66 在 railo.runtime.net.http.HttpServletRequestDummy.clone(HttpServletRequestDummy.java:677):677 在 railo.runtime.thread.ThreadUtil.cloneHttpServletRequest(ThreadUtil.java:67):67 在 railo.runtime.thread.ThreadUtil.clonePageContext(ThreadUtil.java:29):29 在 railo.runtime.thread.ChildThreadImpl(ChildThreadImpl.java:101):101 at railo.runtime.tag.ThreadTag.register(ThreadTag.java:269):269 at at scorecard38.application_cfc $ cf.udfCall(d:\ railo \ web应用\ WWW \ Scorecard38 \的Application.cfc:162):162 at railo.runtime.type.UDFImpl.implementation(UDFImpl.java:94):94
狂野猜测
variables.rc
未被复制到帖子中
答案 0 :(得分:1)
variables.rc
复制到线程中。添加rc
作为参数,然后代替variables.rc
,您将通过arguments.rc
<cfthread name="threadA" action="run" rc="#variables.rc#">
<cftry>
<cfquery>
INSERT INTO dbo.Traffic (Circuit, Fuseaction, IP_hash)
VALUES (<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#listfirst(arguments.rc.fuseaction, '.')#">,
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#listlast(arguments.rc.fuseaction, '.')#">,
<cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#cgi.remote_addr#">
)
</cfquery>
<cfcatch />
</cftry>
</cfthread>
如果这不起作用,您必须删除try
/ catch
并转出cfthread以查看错误。下面的代码将输出'Variable C is undefined'
<cfthread name="threadA" action="run">
<cfset b = c>
</cfthread>
<cfdump var="#cfthread#"><cfabort>
答案 1 :(得分:1)
我遇到了同样的问题。您正在使用CGI变量以及导致问题的原因