我使用两种不同版本的ColdFusion,ColdFusion 9并且两者ColdFusion 10都有所不同XSLT Processors.
ColdFusion 9在使用Apache Xalan时ColdFusion 10正在使用Saxon.
那么,是否有可能改变XSLT Processor?
要么
我们可以使用javax.xml.transform.TransformerFactory类切换到不同的处理器吗?
我只是GET使用一个Rest API请求HttpURLConnection.
我需要添加一些自定义标头,但我null在尝试检索其值时得到.
码:
URL url;
try {
url = new URL("http://www.example.com/rest/");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
// Set Headers
conn.setRequestProperty("CustomHeader", "someValue");
conn.setRequestProperty("accept", "application/json");
// Output is null here <--------
System.out.println(conn.getHeaderField("CustomHeader"));
// Request not successful
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Request Failed. HTTP Error Code: " + conn.getResponseCode());
}
// Read response
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuffer jsonString = new StringBuffer();
String line;
while ((line = br.readLine()) != null) { …Run Code Online (Sandbox Code Playgroud) 我试过了(jsfiddle),但它没有用.
你怎么能看到警报是空的.就像.val()函数在复制字符串之前启动.
$(document).on('paste', '#pasteIt', function(){
alert($("#pasteIt").val());
var withoutSpaces = $("#pasteIt").val();
withoutSpaces = withoutSpaces.replace(/\s+/g, '');
$("#pasteIt").text(withoutSpaces);
});
Run Code Online (Sandbox Code Playgroud)
为什么?
在尝试仅显示某些列时,我正在使用DataTables以及响应和面临的问题.
我需要只显示'Column 1', 'Column3', 'Column 7', 'Column 8', 'Column 10'并隐藏其他(这些应该通过每行末尾的展开控件显示).
JS:
$( 'table' ).DataTable( {
order: [ [ 0, "asc" ] ],
responsive: {
details: {
type: 'column',
target: 'tr'
}
},
columnDefs: [ {
className: 'control',
orderable: false,
targets: -1
} ]
} );
Run Code Online (Sandbox Code Playgroud)
这是JSFiddle.有什么建议!
我正在尝试使用 cfhttp 从自动下载 url 获取文件。我正在使用以下代码:
<cfhttp method="get" url="http://www.example.com/getfile" path="E:/" file="abc.csv">
Run Code Online (Sandbox Code Playgroud)
在这种情况下,我将文件类型指定为 CSV,因此我能够获取文件,但文件类型可以更改。我试图CFHTTP.MIMETYPE获取文件类型并像这样使用:
<cfhttp method="get" url="http://www.example.com/getfile">
<cffile action="write" file="E:/abc.#listLast(cfhttp.MIMETYPE,'/')#" output="#cfhttp.FileContent#">
Run Code Online (Sandbox Code Playgroud)
这适用于 CSV 和 XML 文件。但我希望它也适用于 Excel 文件。
请帮忙。提前致谢。
我试图循环一个2-D尺寸为的数组,12000 * 20我不断得到java.lang.OutOfMemoryError.
最初我认为这可能是因为堆大小所以我增加了我的堆大小但我仍然得到相同的错误.所以我像这样运行垃圾收集器:
<cflock name="checkMemory" type="exclusive" timeout="1" throwontimeout="yes">
<cfset objSystem = CreateObject( "java", "java.lang.System" )>
<cfset objSystem.gc()>
</cflock>
Run Code Online (Sandbox Code Playgroud)
我倾倒了周围的空闲记忆850MB:
<cfset runtime = CreateObject("java","java.lang.Runtime").getRuntime()>
<cfset freeMemory = runtime.freeMemory()>
<cfdump var="#freeMemory#" label="free">
Run Code Online (Sandbox Code Playgroud)
在这里,我试图创建一个XML变量,并在循环时我收到堆错误:
<cfxml variable="variables.XML">
<cfoutput>
<ROWS>
<cfloop from="3" to="#arrayLen(local.array)#" index="i" step="1">
<ROW>
<cfloop from="1" to="#arrayLen(local.array[2])#" index="j" step="1">
<#ucase(local.array[2][j])#>
<![CDATA[#trim(local.array[i][j])#]]>
</#ucase(local.array[2][j])#>
</cfloop>
</ROW>
</cfloop>
</ROWS>
</cfoutput>
</cfxml>
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪:
java.io.WinNTFileSystem.getBooleanAttributes(Native Method)的java.lang.OutOfMemoryError,位于coldfusion的coldfusion.xml.XmlProcessor.getSourceURL(XmlProcessor.java:246)的java.io.File.exists(File.java:733). xml.XmlProcessor.parse(XmlProcessor.java:155)在coldfusion.tagext.lang.XmlTag.doEndTag(XmlTag.java:85)在cffeeds2ecfc1003675922 $ funcDEMO1._factor8(C:\部件\ abc.cfc:1235)在cffeeds2ecfc1003675922 $在coldfusion的coldfusion.runtime.UDFMethod $ ReturnTypeFilter.invoke(UDFMethod.java:405)的coldfusion.runtime.UDFMethod.invoke(UDFMethod.java:472)的funcDEMO1.runFunction(C:\ component\abc.cfc:1192). runtime.UDFMethod $ ArgumentCollectionFilter.invoke(UDFMethod.java:368)在coldfusion.filter.FunctionAccessFilter.invoke(FunctionAccessFilter.java:55)在coldfusion.runtime.UDFMethod.runFilterChain(UDFMethod.java:321)在coldfusion.runtime.UDFMethod .invoke(UDFMethod.java:220)at coldfusion.runtime.CfJspPage._invokeUDF(CfJspPage.java:2582)at …
我只是使用一个cftry/cfcatch块来处理任何异常.拿这个简单的例外:
<cftry>
<cfset abc = 1/0>
<cfcatch>
<cfdump var="#cfcatch.getClass().getName()#">
<cfdump var="#isStruct(cfcatch)#">
<cfdump var="#isObject(cfcatch)#">
<cfdump var="#structKeyExists(cfcatch, 'type')#">
</cfcatch>
</cftry>
Run Code Online (Sandbox Code Playgroud)
以上代码的输出如下:
coldfusion.runtime.DivideByZeroException
NO
YES
YES
Run Code Online (Sandbox Code Playgroud)
我的问题是:
为什么structKeyExists不抛出cfcatch不是类型的错误struct?
倾销cfcatch它似乎是一个struct.
有什么建议.
我CFQuery用来从Oracle DB中检索CLOB字段.如果CLOB字段包含小于~8000的数据,那么我可以看到<CFQuery >检索到的值(<cfdump>o/p),但是如果CLOB字段大小中的值超过8000个字符,那么它不会检索该值.在<cfdump>我可以看到检索为"空字符串"查询虽然Oracle数据库中存在的价值.
我在CFadim控制台中使用Oracle驱动程序,启用"启用长文本检索(CLOB)".和'启用二进制大对象检索(BLOB)."
将"长文本缓冲区(chr)"和"Blob缓冲区(字节)"值设置为6400000
有任何建议来检索全文吗?
我reMatch用来从列表中获取匹配的子字符串.但是当我使用前缀环视时,我收到错误.
序列(?<...)无法识别
码:
<cfset local.path = "schedule.category.classes.name,schedule.category.classes.id">
<cfset local.regex = "(?<=schedule.category.classes.)[a-zA-Z0-9_]*?(?=,|$)">
<cfset local.output = reMatch(local.regex, local.path)>
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我面临一段代码问题,略有修改我得到的结果不同,不应该是这种情况.
版本1给出了正确的结果,我遇到了版本2的问题,这是实际的代码.
版本1:
<cfset keywords = listToArray("1,2,3,4,5,6,7,8,9,10")>
<!--- Common Code Below --->
<cfoutput>#getMetadata(keywords).getName()#</cfoutput>
<cfset toBeAdded = keywords>
<cfset toBeInactivated = listToArray("1,3,4,6,8")>
<cfset toBeActivated = toBeInactivated>
<cfset toBeAdded.removeAll(toBeInactivated)>
<cfset toBeInactivated.removeAll(keywords)>
<cfset toBeActivated.retainAll(keywords)>
Run Code Online (Sandbox Code Playgroud)
版本2:
<cfset keywords = []>
<cfloop from="1" to="10" index="counter">
<cfset arrayAppend( keywords, counter )>
</cfloop>
<!--- If I add following line here then it is working as expected and similar to version 1: --->
<!--- <cfset keywords = listToArray(arrayToList(keywords))> --->
<!--- Common Code Below --->
<cfoutput>#getMetadata(keywords).getName()#</cfoutput>
<cfset toBeAdded = …Run Code Online (Sandbox Code Playgroud) 我有一个 xml 文档,其中有一些日期节点,我试图获取它们的值(如果这些值是有效日期,否则为空字符串)。
XML:
<root>
<START_DATE><![CDATA[03/05/2015]]></START_DATE>
<START_DATE><![CDATA[05/05/2015]]></START_DATE>
<START_DATE><![CDATA[Online]]></START_DATE>
</root>
Run Code Online (Sandbox Code Playgroud)
XSLT:
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0">
<xsl:output method="text" indent="yes" />
<xsl:template match="@*|node()">
<xsl:apply-templates select="@*|node()" />
</xsl:template>
<xsl:template match="START_DATE">
<xsl:copy>
<xsl:value-of select="if(string(normalize-space(.)) castable as xs:date) then normalize-space(.) else ''"></xsl:value-of>
</xsl:copy>
<xsl:text>,</xsl:text>
</xsl:template>
</xsl:transform>
Run Code Online (Sandbox Code Playgroud)
输出:
,,,
Run Code Online (Sandbox Code Playgroud)
预期的:
03/05/2015,05/05/2015,,
Run Code Online (Sandbox Code Playgroud) 我正在写一个ColdFusion函数,如下所示:
<cffunction name="checkStatusCode" output="false" access="private" returnType="void">
<cfif result.Responseheader.Status_Code eq "400">
<cfset isBadRequest = true>
</cfif>
</cffunction>
Run Code Online (Sandbox Code Playgroud)
它都是无效的,不包含任何参数; 我理解如果它有参数并返回一些内容我会怎么称呼它; 我只是将代码放在<cfset>标签中.我只想运行该功能.我需要用什么标签?
我想在ColdFusion中使用if条件,它#firstWordCategory#是否定义了检查变量.
coldfusion ×9
coldfusion-9 ×2
java ×2
jquery ×2
cffile ×1
cffunction ×1
cfhttp ×1
cfloop ×1
cfml ×1
cfquery ×1
clob ×1
datatables ×1
heap ×1
http-headers ×1
regex ×1
removeall ×1
rest ×1
struct ×1
try-catch ×1
xalan ×1
xml ×1
xslt ×1