我是grails的新手,我不知道如何解决这个问题。我需要将服务类中的方法(someserviceclass.groovy)中的数据传递给Grails中的动作控制器。我怎么能这样做?
答案 0 :(得分:0)
class MyController {
def myService
def myAction() {
def values = myService.getData()
[viewVarible: values] // since our method return def we don't need to use return keyword
}
}
class MyService {
def getData() {
def data = [:]
data.put("key1", "value1")
data.put("key2", "value2")
data.put("key3", "value3")
return data // we could have just said data without the return keyword
}
}