gpt4 book ai didi

coldfusion - 使用 CFHTTP 时出错

转载 作者:行者123 更新时间:2023-12-03 12:20:55 26 4
gpt4 key购买 nike

我已经使用 CFML 在 openBD 上构建了一个应用程序。在我使用 CFHTTP 的应用程序中,如下所示:

<cfcomponent output="false">
<cfprocessingdirective pageencoding="utf-8">
<cfset setEncoding("URL", "utf-8")>

<cffunction name="search" access="remote" returnType="any" returnFormat="plain">
<cfargument name="q" type="string" default="" required="yes">
<cfargument name="rows" type="string" default="&rows=120" required="yes">
<cfargument name="score" type="string" default="&sort=score%20desc" required="yes">
<cfargument name="highlight" type="string" default="&hl=true" required="yes">
<cfargument name="json" type="string" default="&wt=json" required="yes">
<cfargument name="phrasehighlighter" type="string" default="&hl.usePhraseHighlighter=true" required="yes">
<cfargument name="filtr" type="string" default="&fq=model:*" required="yes">
<cfargument name="callbackP" type="string" required="false">

<cfset theUrl = 'http://localhost:8090/solr/ktimatologio/select/?hl.requireFieldMatch=true&hl.fl=*&q=' & #Arguments.q# & #ARGUMENTS.rows# & #ARGUMENTS.score# & #ARGUMENTS.highlight# & #ARGUMENTS.json# & #ARGUMENTS.phrasehighlighter#>

<cfhttp url= "#theUrl#" result="rs"></cfhttp>
…………………
…………………
…………………
…………………
</cfcomponent>

当我运行它时出现错误:'无法设置 URL:无效查询'

我该死!这个错误是什么意思?我认为 Adob​​e 的 CFML 引擎工作正常,但我不确定。我的“编程”箭袋里的箭用完了!我需要在 openBD 上让它工作。

尊重,

汤姆

希腊

最佳答案

您应该有一个方法参数(GETPOST,并且您应该删除该端口。将端口添加为port 属性添加到标记中,如下所示:

<cfset theUrl = 'http://localhost:8090/solr/ktimatologio...' />
<cfhttp method="get" url="#theURL#" port="8090" result="rs>

您最好将所有这些查询字符串值添加为 cfhttpparam 标记,而不是将它们附加到您的 URL 上,如下所示:

<cfset theUrl = 'http://localhost/solr/ktimatologio/select/>
<cfhttp method="get" url="#theURL#" port="8090" result="rs>
<cfhttpparam type="URL" name="q" value="#Arguments.q#" />
<cfhttpparam type="URL" name="wt" value="#Arguments.JSON" />
.... more params ....
</cfhttp>

我还强烈建议您从参数中删除查询字符串名称。如果您决定要更改您的实现,您将遇到麻烦...只需接受您要为每个查询字符串值提供的值,而不是值本身的名称。

关于coldfusion - 使用 CFHTTP 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12060984/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com