从CFML到cfscript的cfsavecontent

时间:2017-11-06 22:30:27

标签: coldfusion cfml

我正在尝试在cfscript中编写一个savecontent。

我在CFML中有它:

<cfsavecontent variable="errortext">
    <cfoutput>
        An error occurred: http://#cgi.server_name##cgi.script_name#?#cgi.query_string#<br />
        Time: #dateFormat(now(), "short")# #timeFormat(now(), "short")#<br />

        <cfdump var="#session#" label="Session">
        <cfdump var="#error#" label="Error">
        <cfdump var="#form#" label="Form">
        <cfdump var="#url#" label="URL">

    </cfoutput>
</cfsavecontent>

我在cfscript中需要它,但我怎么能这样做?我可以将所有内容都放在WriteOuput()中吗?

由于

示例不起作用:

<cfscript>
  local.test = "TEST";
  local.OK = "OK";
  savecontent variable="contentViaScript" {
    writeOutput(
      "String Message:  <br />"
      writeDump(local);
    );
  }
  writeOutput(contentViaScript);
</cfscript>

<cfdump var = '#contentViaScript#' />

2 个答案:

答案 0 :(得分:4)

您无需在writedump中包裹writeoutput

<cfscript>
  local.test = "TEST";
  local.OK = "OK";
  savecontent variable="contentViaScript" {
    writeOutput("String Message:  <br />");
    writeDump(local);
  }
  writeOutput(contentViaScript);
</cfscript>

<cfdump var = '#contentViaScript#' />

DEMO

答案 1 :(得分:-2)

试试这个:

<cfscript>
  local.test = "TEST";
  local.OK = "OK";
  savecontent variable="contentViaScript" {
    writeOutput(
      "String Message:  <br />
      #writeDump(local)#"
    );
  }
  writeOutput(contentViaScript);
</cfscript>

<cfdump var = '#contentViaScript#' />