2
static def lemp(String aKey,String userName,String tType){
        def temp
         try {
           def ret = null
           def http = new HTTPBuilder("http://192.168.1.10:8080/Pay-0.1/main/msgPicTemp")
           http.parser.'text/html' = http.parser.'text/plain'
           http.request(Method.GET, ContentType.TEXT) {
               uri.query = [ appKey:appKey, userName:userName,tempType:tempType]
               headers.'User-Agent' = 'Mozilla/5.0 Ubuntu/8.10 Firefox/3.0.4'
               response.success = { resp,reader -> println resp.status


            println reader.text
                temp=reader.text//i got error here,how to assign this to one variable and pass it to controller
                 }
               response.failure = { resp -> println "Unexpected error: ${resp.status} : ${resp.statusLine.reasonPhrase}" }
           }

          return temp
       } catch (groovyx.net.http.HttpResponseException ex) {
           ex.printStackTrace()
           return null
       } catch (java.net.ConnectException ex) {
           ex.printStackTrace()
           return null
       }
   }

ここで、リーダーは次のようなコードを提供します。

 <link rel="stylesheet" href="/Pay-0.1/static/css/bootstrap.css" type="text/css">
    <div align="left" style="background-color:#B8B8B8;width:150px">
    </div>
    Welcome

このリーダーを1つの変数に割り当ててコントローラーに戻る方法.そして、コントローラーからこの1ページを表示したい.

4

1 に答える 1

4

問題はあなたのものだと思いますprintln reader.text。ストリームから読み取ると、ストリームが閉じます。したがって、変数を設定する次の行は機能しません。を削除してprintln reader.text、まだ問題があるかどうかを確認します

于 2013-02-06T15:56:01.283 に答える