0

我收到以下错误消息。我已经在 handlers 目录中创建了 Uploads.cfc 处理程序。检查了一切,找不到解决方案。

错误类型:HandlerService.EventHandlerNotRegisteredException:[N/A]

错误消息:事件:上传是无效的注册事件。

这是 Uploads.cfc 代码:

<!--- Default Action --->
<cffunction name="index" returntype="string" output="false" hint="My main event">
    <cfargument name="event">
    <cfargument name="rc">
    <cfargument name="prc">  
    
    <cfobject component="model.Uploader" name="fileUploader">
    <cfset filesJson = fileUploader.Upload(rc.file)>
    
    <cfreturn filesJson>
</cffunction>

你能建议一个解决方案吗?

4

3 回答 3

3

您不必重新启动整个 CF 服务器。您只需要重新初始化 ColdBox。只需将?fwreint=或添加?fwreint={password}到 URL。密码设置在ColdBox.cfc:“reinitpassword”中。您还可以配置ColdBox.cfc为不在非生产环境中缓存处理程序。

如果您使用的是 ColdBox 3.6 或更高版本,则无需再定义event, rc and prc

<cffunction name="index" returntype="string" output="false" hint="My main event">
    <cfobject component="model.Uploader" name="fileUploader">
    <cfset filesJson = fileUploader.Upload(rc.file)>
    <cfreturn filesJson>
</cffunction>

其次,您应该使用WireBox而不是在执行过程中动态创建对象。最后,不要将特定于函数的变量定义到variables处理程序 CFC 文件的范围内。为它们加上前缀local以确保这些变量是“函数本地的”:仅可用于使用它们的特定函数。

<cffunction name="index" returntype="string" output="false" hint="My main event">
    <cfset local.fileUploader = getModel("Uploader") >
    <cfset local.filesJson = fileUploader.Upload(rc.file)>
    <cfreturn local.filesJson>
</cffunction>
于 2014-06-09T19:39:28.600 回答
2

我过去也遇到过同样的问题。尝试重新启动 ColdFusion 应用程序服务器。

于 2014-06-09T19:12:18.347 回答
0

iKnowKungFu 拼写错误 ?fwreint= (缺少 i) 应该是 ?fwreinit

于 2014-06-28T12:50:19.283 回答