Search code examples
grailsserviceimportgsp

How to import a service that is in a package into a gsp file in Grails


Possible Duplicate:
Problem calling grails service from gsp

I have a service called HeaderService that is in a package called application in a project called Portfolio. How can i import this service into a gsp? I have tried

<%@ page import="com.portfolio.application.HeaderService" %>

And many variations, but It doesnt work. Anyone have any suggestions? Thanks!


Solution

  • You can access your services through the applicationContext object that's implicitly available in views. Example:

    <%= applicationContext.headerService.doSomething() %>