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

如何将此阅读器分配给一个变量并返回到控制器。我想从控制器显示这一页。

4

1 回答 1

4

我相信问题出在你的println reader.text. 从流中读取会关闭流。所以你的下一行,设置变量是行不通的。删除println reader.text,看看是否还有问题

于 2013-02-06T15:56:01.283 回答