我刚刚开始在一个新项目中使用 Hibernate,对于我的第一个实体,我遇到了一个错误,我似乎无法弄清楚。
我现在的架构只有两个表:大洲和国家,其中国家/地区有一个 ContinentalID 外键。
当我尝试运行调用大陆实体的代码时,我得到一个空白页面。所有处理都会停止,但不会显示任何错误。当我通过 MXUnit 运行代码时,我实际上收到了一个错误。错误信息很简单Could Not Load an Entity: [continent#1]。异常的原因是org.hibernate.exception.SQLGrammarException。这就是我得到的全部。
我的实际实体代码是:
大陆.cfc
component tablename='continents' persistent=true output=false{
property name='id' type='numeric' fieldtype='id' datatype='integer';
property name="name" type='string' length='45';
property name='bonus' type='numeric';
property name='countries' type='array' fieldtype='one-to-many' cfc='Country' singularname='country' inverse='true' fkcolumn='continentid' cascade='all-delete-orphan';
public Country function init(string name='', numeric bonus=0){
setName(Arguments.name);
return this;
}
}
Run Code Online (Sandbox Code Playgroud)
国家.cfc
component tablename='countries' persistent=true output=false{
property name='id' type='numeric' fieldtype='id' datatype='integer' generator="identity";
property name="name" type='string' length='45';
property name='continent' fieldtype='many-to-one' fkcolumn='continentid' cfc='Continent' missingRowIgnored=true;
public Country function …Run Code Online (Sandbox Code Playgroud) 我正在尝试将文件上传添加到我的 CFWheels + Railo 应用程序中。但在尝试使用时我不断收到此错误消息<cffile action="upload">:
Form field [asset[file]] doesn't exist or has no content
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
我更喜欢动态地执行此操作,而不是将查询中的列硬编码到表中。这是我从另一个来源调整的代码。我想要做的不仅是按顺序获取列,还要获取每列的行值。我似乎找不到使用此方法显示每列的实际行值的属性,仅显示列名称和类型。
在两个 cfloop 中,顶部的一个将表示列名称,而底部的一个将表示该列的行值。
cfset employeemeta=getMetaData(ShowDeletedData)>
<Table border="1">
<TR>
<h4>The Employees table has the following columns</h4>
<cfloop index="i" from="1" to="#arrayLen(employeemeta)#">
<cfoutput>
<TD> #employeemeta[i].name# </TD>
</cfoutput>
</cfloop>
</TR>
<TR>
<cfloop index="i" from="1" to="#arrayLen(employeemeta)#">
<cfoutput>
<TD> #employeemeta[i].name# </TD>
</cfoutput>
</cfloop>
</TR>
</table>
Run Code Online (Sandbox Code Playgroud) 我想在我的网络服务器上调用 cfc 文件,但总是收到错误:未提供所需的参数 [UserID]。
冷融合代码:
<CFINVOKE component="changeTree" method="getTreeWidth" returnVariable="httpTreeWidth">
<cfinvokeargument name="UserID" value="#checklogin.UserID#">
</CFINVOKE>
Run Code Online (Sandbox Code Playgroud)
更改树.cfc:
<CFFUNCTION name="getTreeWidth">
<CFPARAM name="UserID" required="true">
...
Run Code Online (Sandbox Code Playgroud)
感谢帮助。
如果我的项目位于不同的文件(modals.cfm)中,我将创建所有模态。如何从另一个文件调用模式?
modals.cfm(引导模态示例)
<div class="modal fade" id="requestError" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button aria-hidden="true" data-dismiss="modal" class="close" type="button">X</button>
<h4 id="myModalLabel1" class="modal-title"><strong>Error!</strong></h4>
</div>
<div class="modal-body">
<div class="alert alert-danger fade in">
<h2 id="error"></h2>
</div>
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" type="button">Close</button>
<button data-dismiss="modal" class="btn btn-primary" type="button" onClick="myFunc();">Confirm</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
然后,我想从另一个 cfm 文件中调用它。例如,index.cfm:
<button type="button" class="btn btn-primary" onClick="callModal();"> Test </button>
<script>
function callModal(){
$("#error").html("My custom error message");
$("#requestError").modal(); // How can I call it from another file?
} …Run Code Online (Sandbox Code Playgroud) 我了解 SQL sum 函数。这是我的代码:
<cfquery name="sum" datasource="expense_db" username = "for" password = "bar">
SELECT sum(amount)
FROM expense
</cfquery>
Run Code Online (Sandbox Code Playgroud)
如何输出查询结果?我只想输出金额列的 SUM
我想将秒转换为天、小时和分钟 目前,它仅适用于小时和分钟,但不适用于天。你能支持我吗?告诉我我做错了什么:
<cfscript>
seconds = '87400';
midnight = CreateTime(0,0,0);
time = DateAdd("s", seconds, variables.midnight);
date= xxxxxxxxxxxxxxxxxxxxx???
</cfscript>
<cfoutput>
#DateFormat(variables.date, 'd')# not working
#TimeFormat(variables.time, 'HH:mm')#
</cfoutput>
Run Code Online (Sandbox Code Playgroud)
对于该值,87400预期结果是
如果我花94152几秒钟,它将是:
我唯一的问题是获得正确的日期...显示小时和分钟,但不是正确的日期
感谢大家的支持
我正在致力于加密 URL 并将工作脚本从 PHP 转换为 ColdFusion。我已经完成了 95% 的工作,但在尝试了 StackOverflow 上的许多解决方案后,我陷入了困境。我的结果仍然不匹配。我确认两个脚本上的saltBin和keyBin值是相同的。请看一看。
PHP版本
\n$saltBin = R\xef\xbf\xbdk\xef\xbf\xbd\xef\xbf\xbdE\xef\xbf\xbdx^ \xef\xbf\xbdO<\xef\xbf\xbd-\xef\xbf\xbd7J=S\xef\xbf\xbdz\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd \xef\xbf\xbd;\n$keyBin = \xef\xbf\xbd;B\xef\xbf\xbd\xef\xbf\xbd|\xef\xbf\xbd \xef\xbf\xbd0U,\xef\xbf\xbd\xef\xbf\xbdh\xef\xbf\xbdNS+\xef\xbf\xbd\xef\xbf\xbd.\xef\xbf\xbd\xef\xbf\xbdG\xef\xbf\xbd\xef\xbf\xbd\xef\xbf\xbd\n\nres = hash_hmac(\'sha256\', $saltBin, $keyBin);\nresult\n39ddcd6156a30fdcebc9fbf5dd59a0ef4f47e27841bbc12ce72b64a0a63c0324\nRun Code Online (Sandbox Code Playgroud)\n冷聚变版本
\n<cfset res = hmac(saltBin,keyBin,"HMACSHA256")>\nresult\n30A658BEB3965C2D7D27A3F717FB6C13B05ED44E8B2A5A7FEBB9B57887CF57A0\nRun Code Online (Sandbox Code Playgroud)\n我尝试过以下解决方案
\n\nColdfusion哈希以及hmacSHA256和SHA256之间的区别
\n更新:
\n下面是PHP版本的缩写版本
\n$key = \'943b421c9eb07c830af81030552c86009268de4e532ba2ee2eab8247c6da0881\';\n$salt = \'520f986b998545b4785e0defbc4f3c1203f22de2374a3d53cb7a7fe9fea309c5\';\n$keyBin = pack("H*" , $key);\n$saltBin = pack("H*" , $salt);\n$path = "/rs:fill:300:300:1/g:no/aHR0cDovL2ltZy5leGFtcGxlLmNvbS9wcmV0dHkvaW1hZ2UuanBn.png";\necho hash_hmac(\'sha256\', $saltBin.$path, $keyBin);\nRun Code Online (Sandbox Code Playgroud)\n结果:7062c2b5786c82de963767de4b0cdbc4e7ed7db2ce7466708bf8a28d8572888b
<cfset key = \'943b421c9eb07c830af81030552c86009268de4e532ba2ee2eab8247c6da0881\'>\n<cfset salt …Run Code Online (Sandbox Code Playgroud) 我从另一个应用程序收到一个包含各种信息的字符串。这些项目始终处于相同的顺序,但可变信息的长度可以改变。每个项目由下划线分隔,并以字母和冒号为前缀。
例子:
答:12345678_B:5482945_C:20220911_D:20230402_E:3.94
理想情况下,我想将其分解,以便(在 Coldfusion 中)我最终可以得到一系列变量,我将它们设置为上面的 A、B、C、D 和 E 的值。
有谁知道有什么简单的方法可以做到这一点?
谢谢!
我正在尝试根据查询进行可配置的打印。
<cfloop query="#query_name#">
<tr class="tabledetail">
<cfloop array="#col_db_names#" index="colname">
<td valign="middle" class="detaildata" nowrap>
#query_name#.#colname#
</td>
</cfloop>
</tr>
</cfloop>
Run Code Online (Sandbox Code Playgroud)
问题是,我现在不知道如何显示数据,因为我只得到这个输出:
感谢您的帮助,我对 ColdFusion 还很陌生。