是否可以检查 cookie 何时到期?我尝试了以下方法:
首先我设置了三个cookie:
<cfcookie name="test1" value="" expires="10" />
<cfcookie name="test2" value="" expires="never" />
<cfcookie name="test3" value="" expires="now" />
Run Code Online (Sandbox Code Playgroud)
然后在另一个页面上我检查 cookie 数据:
<cfset cookies = getPageContext().getRequest().getCookies()>
<Cfoutput>
<cfloop index="c" array="#cookies#">#c.getName()#:#c.getMaxAge()#<br>
</cfloop>
</Cfoutput>
Run Code Online (Sandbox Code Playgroud)
但是MaxAge返回-1所有 cookie 而不是实际到期日期。我怎样才能得到实际的到期日期?
我发现该valuelist()函数不喜欢动态命名的查询:
<cfscript>
variables.nNumber = 1;
request.qDirectories = new query();
request.qDirectories.setDBType('query');
request.qDirectories.setAttributes(qDirectories=request.qAllDirectories);
request.qDirectories.setSQL("SELECT id, name, abbr, multiproperties, isPublished,
isArchived, dateAdded, lastModified, lastModifiedBy,
prefix, lstJournalCodes FROM qDirectories");
request["qDirectories#variables.nNumber#"] = request.qDirectories.execute().getResult();
writeDump(valueList(request["qDirectories#variables.nNumber#"].id));
</cfscript>
Run Code Online (Sandbox Code Playgroud)
在发现这一点后,我认为arrayToList()会有所帮助.它确实有帮助,但即使有多行,它也只会带回一个值的数组.
有没有办法从动态命名的查询中获取特定列的所有值?
我有一个简单的表单,有四个字段名为firstName,lastName,地址和电话号码.
用户填写此表单并单击提交按钮后,如果一切正常,我将该用户重定向到成功页面.
但是,在成功页面中单击浏览器后退按钮时,表单字段值将在表单上重新填充.我怎样才能防止这种情况发生?
我已经尝试过这段代码:
<cfheader name="cache-control" value="no-cache, no-store, must-revalidate">
<cfheader name="pragma" value="no-cache">
<cfheader name="expires" value="#getHttpTimeString(now()-1)#">
Run Code Online (Sandbox Code Playgroud)
但它没有用.
FindNoCase和Find函数都为所有情况返回0值.我正在研究Coldfusion 9.
<cfoutput>#Find("aaInternationalbb", "International")#</cfoutput> ->o/p:0
<cfoutput>#Find("aalbb", "International")#</cfoutput> ->o/p:0
<cfoutput>#FindNoCase("aaInternationalbb", "International")#</cfoutput> ->o/p:0
<cfoutput>#FindNoCase("aalbb", "International")#</cfoutput> ->o/p:0
Run Code Online (Sandbox Code Playgroud)
请让我知道如何使这项工作.提前致谢
我有一个原型功能.我想将它包装在函数标记周围,然后从cfform中的按钮调用它.有可能吗?我该怎么办?
我试过这个,但是我得到一个错误,说数组没有定义.所有帮助表示赞赏.
<cfscript >
function calculateTotal(){
var Price = Array();
var Quantity = Array();
$$('.x-grid3-col-PRICE').each(function(el){Price[Price.length] = el.innerHTML; });
$$('.x-grid3-col-QUANTITY').each(function(el){Quantity[Quantity.length] = parseInt(el.innerHTML); });
var Totals = 0;
for (var index = 0; index < Price.length; ++index) {
if (!isNaN(Price[index]) && !isNaN(Quantity[index]))
{
Totals = Totals + (Price[index] * Quantity[index]);
}
}
$('total').value = Totals;
return true;
}
</cfscript>
<cfform>
<cfinput type="Button" name="submit" value="Calculate Order" onclick="#calculateTotal()#">
<cfinput type="Text" name="total" disabled="true" label="Total $" size="5">
</cfform
Run Code Online (Sandbox Code Playgroud) 我有一个小函数,使用ColdFusion 9和jQuery从我的数据库中删除记录
该函数存在于其他3个位置,它是相同的并且按预期运行,但它似乎与此页面有错误.
Html表单代码
<form name="devRatingCat" method="post" action="" >
<table class="table table-bordered table-striped" >
<tr>
<th> </th>
<th>ID</th>
<th>Category Name</th>
</tr>
<cfloop query="categories">
<tr>
<td><input class="checkbox" type="checkbox" name="mark" value="#recID#"></td>
<td>#recID#</td>
<td>#categoryname#</td>
</tr>
</cfloop>
</table>
<hr />
<div class="pull-left">
<button class="btn btn-danger" type="button" onClick="dlteCatR(mark);" >Delete</button>
</form>
Run Code Online (Sandbox Code Playgroud)
jQuery的
function dlteCatR(field)
{
var $srt = $(field);
var r = confirm("Are you sure you want to delete this Category? \n You will not be able to revert this change!")
if(r==true){
for(i=0; i<$srt.length; i++){
if($srt[i].checked == …Run Code Online (Sandbox Code Playgroud) 我在Windows 10上安装了ColdFusion 10,并使用HotFix no 18(适用于Windows 10)进行了强制更新.重新启动Windows服务器后,服务不存在,我收到以下错误:
Error loading: D:\\ColdFusion10\\jre\bin\server\jvm.dll
Run Code Online (Sandbox Code Playgroud) 我正在使用ColdFusion 10.如何指定我的连接是TLS 1.1,TLS 1.0等.我可以使用cfhttp标签吗?
如何cfhttp使用ColdFusion 在标签中添加TLS 1.2 ?
我在尝试使用时遇到问题cfhttp。我使用的API要求我发送登录凭据,然后发送后续命令。对后续命令的答复是“需要登录”。在查看了我的请求之后,我认为我已经找到了问题,但我不理解。
这是我的登录电话:
<cfhttp url="#Target#" result="LoginAttempt" method="POST" REDIRECT="No" useragent="#strUserAgent#">
<cfhttpparam type="FORMFIELD" name="action" value="Login" />
<cfhttpparam name="loginUsername" value="#Username#" type="FORMFIELD" />
<cfhttpparam name="loginPassword" value="#Password#" type="FORMFIELD" />
</cfhttp>
Run Code Online (Sandbox Code Playgroud)
当返回时200 OK,我将cookie设置为用于将来的调用:
<cfset ThisCookie = LoginAttempt.responseHeader["Set-Cookie"] />
Run Code Online (Sandbox Code Playgroud)
然后,继续下一个调用:
<cfhttp url="#Target#" result="CreateTransactionAttempt" method="POST" REDIRECT="No" useragent="#strUserAgent#">
<cfhttpparam type="header" name="Cookie" value="#ThisCookie#" />
<cfhttpparam type="FORMFIELD" name="action" value="CreateTransaction" />
<cfhttpparam type="FORMFIELD" name="transactionName" value="#TransactionName#" />
</cfhttp>
Run Code Online (Sandbox Code Playgroud)
我认为的问题是 当我查看第二个cfhttp调用的标题时,它与第一个调用提供的cookie不匹配。我不确定为什么会这样。在本纳德尔的博客页面在这里,他有分裂返回的cookie到一个结构并传递到第二个呼叫的功能。我已经尝试了相同的结果。我想念什么吗?
向 Stripe API 发送 http 调用以获取 Auth-token,但以下代码引发错误:开始标记必须具有匹配的结束标记。可以通过添加</cffunction>. 如果标签的正文为空,则可以使用快捷方式<cffunction .../>.....
<cffunction name="getAuthToken" access="private" output="false">
<cfhttp url="#variables.server#/v1/tokens" method="post" password="#variables.password#">
<cfargument name="req" required="true" type="any">
<cfhttpparam type="header" name="Content-Type" value="application/x-www-form-urlencoded">
<cfhttpparam type="header" name="Accept-Language" value="en_US">
<cfhttpparam type="body" value="#req#">
</cfhttp>
<cfset response = deserializeJSON(cfhttp.FileContent)>
<cfreturn response>
</cffunction>
Run Code Online (Sandbox Code Playgroud) coldfusion ×10
coldfusion-9 ×4
cfml ×2
ajax ×1
browser ×1
caching ×1
cfcookie ×1
function ×1
javascript ×1
jquery ×1
tls1.2 ×1
windows-10 ×1