ColdFusion: get url parameter by name

2019-01-18 23:48发布

I want to get in ColdFusion 10 an URL parameter from CGI.QUERY_STRING by its name. How to do it without looping?

1条回答
Bombasti
2楼-- · 2019-01-19 00:49

Any values passed in to a page via the query string are available in the URL scope.

Assume you have a query string that looks like http://mydomain.com?val1=42&val2=moo you would access the variables by referencing them as such

<cfset myVal1 = url.val1 />
<cfset myVal2 = url.val2 />

Or, in cfscript

myVal1 = url.val1;
myVal2 = url.val2;

To see all the values passed in via query string, you can also dump out the URL scope.

<cfdump var="#url#" />

or, in cfscript

writeDump( url );
查看更多
登录 后发表回答