本文介绍了白色空间/冷灌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

停止ColdFusion输出的空​​格的正确方法是什么?

What would be the correct way to stop the white space that ColdFusion outputs?

我知道有 cfcontent cfsetting enableCFoutputOnly

推荐答案

除了< cfsilent> < cfsetting enablecfoutputonly =yes> &cf; cfupcessingdirective suppressWhiteSpace =true> < cfcontent reset =true/> 。您可以使用文档开头删除空格。

In addition to <cfsilent>, <cfsetting enablecfoutputonly="yes"> and <cfprocessingdirective suppressWhiteSpace = "true"> is <cfcontent reset="true" />. You can delete whitespaces at the beginning of your document with it.

HTML5文档将以如下方式开始:

HTML5 document would then start like this:

<cfcontent type="text/html; charset=utf-8" reset="true" /><!doctype html>

XML文档:

<cfcontent reset="yes" type="text/xml; charset=utf-8" /><CFOUTPUT>#VariableHoldingXmlDocAsString#</CFOUTPUT>

这样你就不会得到Content is not allowed in prolog - XML文档的错误。

This way you won't get the "Content is not allowed in prolog"-error for XML docs.

如果你从一个函数中得到不需要的空格,使用输出 -attribute来抑制任何输出, result as string - 例如:

If you are getting unwanted whitespaces from a function use the output-attribute to suppress any output and return your result as string - for example:

<cffunction name="getMyName" access="public" returntype="string" output="no">
  <cfreturn "Seybsen" />
</cffunction>

这篇关于白色空间/冷灌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 14:08