how to call service from controller in grails

2019-05-05 03:19发布

I have a service class and i am trying to call the method of the service in my controller as below.

class LogListController {

def ListLogDetails = { 
    println "We are inside List log Details-->"+params
    def logListHelperService
    logListHelperService.getFilePath(params)
}}

Exception Message: Cannot invoke method getFilePath() on null object

what is my mistake there..

1条回答
做自己的国王
2楼-- · 2019-05-05 04:04
def logListHelperService

must be declared outside of the ListLogDetails definition

def logListHelperService
def ListLogDetails = { 
    println "We are inside List log Details-->"+params
    logListHelperService.getFilePath(params)
}

should work

查看更多
登录 后发表回答