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

如何将这个读者分配给一个变量并返回controller.and我想从 Controller 显示这一页。

最佳答案

我相信问题出在您的println reader.text上。从流中读取将关闭流。因此,设置变量的下一行将不起作用。删除println reader.text,看看是否还有问题

10-04 11:08