1

To render JSON+HAL I've added @Resource anotation to my domain:

@Resource(uri = "/rest/book", formats=['hal'])
class Book {
    String title
    String author
}

The problem is that I already have BookController (no scaffolding) and creating ling via gsp tag (<g:createLink controller='book' />) always creates link to /rest/book not to specyfic action in controller (i.e. /book/index). What is also worth knowing when I type localhost:8080/book/index it is showing JSON response not gsp page.

The @Resource somehow cover the book controller and I don't know how to keep both of them working.

PS I'm using Grails 2.4.4

saw303
  • 8,051
  • 7
  • 50
  • 90
MAGx2
  • 3,149
  • 7
  • 33
  • 63

1 Answers1

1

Use namespaces for your controller.

class BookController {

    static namespace = 'namespaceOne'

    // …
}

and then use the namespace to generate links to your BookController.

<g:link controller="book" namespace="namespaceOne">Click me</g:link>
saw303
  • 8,051
  • 7
  • 50
  • 90