且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Coldfusion:通过url将结构作为字符串传递

更新时间:2023-02-18 16:55:17

<cfscript>
// create simple struct
x = { a=1, b=2, c=3 };
WriteDump(x);

// serialize in JSON format and encode for URL transport
y = URLEncodedFormat( SerializeJSON(x));
WriteOutput( 'url: <a href="#SCRIPT_NAME#?z=#y#">#SCRIPT_NAME#?#y#</a>');

// now receive the URL variable and dump it
if ( StructKeyExists( url, 'z' )) {
    writeOutput( '<h3>URL Data:</h3>' );
    writeDump( DeserializeJSON( URLDecode( z)));
}
</cfscript>