我使用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:无效查询’。
我被卡住了!这个错误意味着什么?我认为Adobe的CFML引擎正在正常工作,但我不确定。我的“编程”箭已经用完了!.I需要让它在openBD上工作。
恕我直言
汤姆
希腊
发布于 2012-08-21 19:53:28
您应该有一个method参数( GET或POST ),并且应该移除端口。将端口作为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>我还强烈建议您从参数中删除querystring名称。如果你决定改变你的实现,你就会有麻烦.只接受要为每个querystring值提供的值,而不是值本身的名称。
https://stackoverflow.com/questions/12060984
复制相似问题