How do I call a Grails service from a gsp?

后端 未结 4 774
一整个雨季
一整个雨季 2020-12-05 02:33

How can I invoke a service directly from a view? I\'m trying with ${my.domain.service.method}, but it complains it can\'t find the property.

And no, I

4条回答
  •  萌比男神i
    2020-12-05 03:06

    I think the best way of doing it is:

    <%
        def myService = grailsApplication.mainContext.getBean("myService");
    %>
    

    This way, you get the service instance without losing the autowired services.

提交回复
热议问题