coldfusion - ColdFusion 中的错误处理 LT

标签 coldfusion

我正在编写我的第一个 ColdFusion 组件,但出现此错误。有谁知道这意味着什么?

Invalid CFML construct found on line 2 at column 1.
ColdFusion was looking at the following text:
<
The CFML compiler was processing:
< marks the beginning of a ColdFusion tag.Did you mean LT or LTE?
The error occurred in C:/inetpub/wwwroot/ColdFusion/test.cfm
<cfcomponent displayname="News" hint="Get News">
<cffunction name="GetNews" returntype="query">
<cfquery datasource="CFDatabase" name="myQuery"

源代码:
<cfcomponent displayname="News" hint="Get News">
<cffunction name="GetNews" returntype="query">
    <cfquery datasource="CFDatabase" name="myQuery">
        select * from tbNews
    </cfquery>
    <cfreturn myQuery>
</cffunction>
</cfcomponent>

<cfinvoke component="components.News" method="GetNews" returnvariable="AllNews">

<table width="100%">
<cfoutput query="AllNews">
<tr>
    <td>Title:</td>
    <td><cfoutput>#myQuery.Title#</cfoutput></td>
    <td>Body:</td>
    <td><cfoutput>#myQuery.Description#</cfoutput></td>
</tr>
</cfoutput>
</table>

最佳答案

您已放置 <cfcomponent>在 cfm 文件中,这是我不允许的。

移动 <cfcomponent>阻塞到扩展名为 .cfc 的文件(例如 News.cfc),然后从您的 .cfm 文件中调用它

在 News.cfc

<cfcomponent>
<cffunction name="getNews">
...
</cffunction>
</cfcomponent>

在 test.cfm
<cfset newsObj = createobject('component', 'News')>
<cfset AllNews = newsObj.getNews()>

关于coldfusion - ColdFusion 中的错误处理 LT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13358915/

相关文章:

mysql - 在 MySQL 中使用 OR 和 HAVING 与使用 AND

Coldfusion 如何重复另一个案例的相同任务

coldfusion - ColdFusion 用户定义函数名称的有效字符是什么?

redirect - 404 错误自定义页面适用于 .cfm 扩展名,但不适用于 .html?

coldfusion - Coldfusion 9 使用什么版本的 iText?

coldfusion - 从表单中按顺序显示 CFLoop 项目

mysql - Coldfusion SQL 查询在一个查询中选择和更新

jQuery 数据表仅搜索一列

javascript - 首次在现有站点上启动时找出所有链接的 css/js

email - 更改 CFMail 中附件的文件名