These several days i’ve been searching on how to map url request to the controller, and finally found it. First i code it in java, but i face some problems and move it into groovy. Here is the code
ApplicationContext ctx = (ApplicationContext) org.codehaus.groovy.grails.web.context.ServletContextHolder.getServletContext().getAttribute(org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes.APPLICATION_CONTEXT);
def grailsApp = ctx.getBean("grailsApplication")
def controllerName = ctx.getBean("grailsUrlMappingsHolder").match(request.getServletPath()).getParameters().controller
def controllerInstance = grailsApp.getArtefactByLogicalPropertyName("Controller", ctrlName)
Advertisement