首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用CFHTTP时出错

使用CFHTTP时出错
EN

Stack Overflow用户
提问于 2012-08-21 18:36:02
回答 1查看 1.4K关注 0票数 3

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

代码语言:javascript
复制
<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上工作。

恕我直言

汤姆

希腊

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-21 19:53:28

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

代码语言:javascript
复制
<cfset theUrl = 'http://localhost:8090/solr/ktimatologio...' />
<cfhttp method="get" url="#theURL#" port="8090" result="rs>

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

代码语言:javascript
复制
<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值提供的值,而不是值本身的名称。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12060984

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档