小编Beg*_*ner的帖子

切换到ColdFusion中的不同XSLT处理器

我使用两种不同版本的ColdFusion,ColdFusion 9并且两者ColdFusion 10都有所不同XSLT Processors.

ColdFusion 9在使用Apache XalanColdFusion 10正在使用Saxon.

那么,是否有可能改变XSLT Processor

要么

我们可以使用javax.xml.transform.TransformerFactory类切换到不同的处理器吗?

java coldfusion coldfusion-9 coldfusion-10

15
推荐指数
1
解决办法
405
查看次数

使用HttpURLConnection设置自定义标头

我只是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)

java rest urlconnection httpurlconnection http-headers

8
推荐指数
2
解决办法
3万
查看次数

使用jQuery粘贴后删除空格

我试过了(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)

为什么?

jquery

7
推荐指数
1
解决办法
2239
查看次数

DataTable响应显示某些列

在尝试仅显示某些列时,我正在使用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.有什么建议!

jquery datatables datatables-1.10

7
推荐指数
1
解决办法
2万
查看次数

从coldfusion中的自动下载网址获取文件

我正在尝试使用 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 文件。

请帮忙。提前致谢。

coldfusion cffile cfhttp

6
推荐指数
1
解决办法
2592
查看次数

在coldfusion中循环时避免堆错误

我试图循环一个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 …

heap coldfusion coldfusion-9 cfloop

6
推荐指数
1
解决办法
467
查看次数

ColdFusion中的cfcatch类型

我只是使用一个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.

有什么建议.

coldfusion struct try-catch

6
推荐指数
3
解决办法
1368
查看次数

使用CFQuery检索长文本(CLOB)

CFQuery用来从Oracle DB中检索CLOB字段.如果CLOB字段包含小于~8000的数据,那么我可以看到<CFQuery >检索到的值(<cfdump>o/p),但是如果CLOB字段大小中的值超过8000个字符,那么它不会检索该值.在<cfdump>我可以看到检索为"空字符串"查询虽然Oracle数据库中存在的价值.

我在CFadim控制台中使用Oracle驱动程序,启用"启用长文本检索(CLOB)".和'启用二进制大对象检索(BLOB)."

将"长文本缓冲区(chr)"和"Blob缓冲区(字节)"值设置为6400000

有任何建议来检索全文吗?

coldfusion cfquery clob

5
推荐指数
1
解决办法
4191
查看次数

正则表达式前缀外观不适用于coldfusion 10

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)

我错过了什么?

regex coldfusion coldfusion-10

5
推荐指数
1
解决办法
191
查看次数

ColdFusion中数组的奇怪行为

我面临一段代码问题,略有修改我得到的结果不同,不应该是这种情况.

版本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)

coldfusion removeall cfml coldfusion-11

5
推荐指数
1
解决办法
120
查看次数

检查 XSLT 中的字符串是否为有效日期

我有一个 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>&#44;</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)

xml xslt xalan

3
推荐指数
1
解决办法
7617
查看次数

如何在没有参数的情况下调用无效的ColdFusion函数

我正在写一个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 cffunction

0
推荐指数
1
解决办法
727
查看次数

如何在ColdFusion中检查变量是否已定义

我想在ColdFusion中使用if条件,它#firstWordCategory#是否定义了检查变量.

coldfusion

-2
推荐指数
2
解决办法
3322
查看次数