location函数(cflocation标签)中的addtoken参数是否为布尔值?

时间:2015-07-17 10:56:17

标签: coldfusion coldfusion-9 cfml

我正在使用CF9。

函数cflocation有一个参数

addToken = "yes|no"

如果这实际上是布尔值,则不提及,例如是以下两个等价物?

<cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "no">
<cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "false">

使用该函数在cfscript中调用此方法时 Location我可以传递boolean作为参数吗?

<cfscript>
   location(url="http://localhost:8500/administrator", addtoken = false);
</cfscript>

1 个答案:

答案 0 :(得分:4)

是的,它们是相同的,是的,您可以将它们作为参数传递给cfscript。你甚至可以使用0和1。

对于错误:

<cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "no">
<cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "false">
<cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "0">
<cfscript>location(url="http://localhost:8500/cfdocs/dochome.htm", addtoken = false);</cfscript>
<cfscript>location(url="http://localhost:8500/cfdocs/dochome.htm", addtoken = "no");</cfscript>
<cfscript>location(url="http://localhost:8500/cfdocs/dochome.htm", addtoken = 0);</cfscript>

对于true:

<cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "yes">
<cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "true">
<cflocation url = "http://localhost:8500/cfdocs/dochome.htm" addToken = "1">
<cfscript>location(url="http://localhost:8500/cfdocs/dochome.htm", addtoken = true);</cfscript>
<cfscript>location(http://localhost:8500/cfdocs/dochome.htm", addtoken = "yes");</cfscript>
<cfscript>location(url="http://localhost:8500/cfdocs/dochome.htm", addtoken = 1);</cfscript>

顺便说一下,您可以通过创建一个小样本文件并对其进行测试来轻松验证这一点。