Jersey Sub-Resource Locators Error

后端 未结 1 1935
情深已故
情深已故 2021-01-25 02:02

I\'m trying to get the JSR-311 plugin working with Grails 2.3.7. I\'m using version 0.10, because I think 0.11 requires Grails 2.4.

I\'ve used the generate-resourc

相关标签:
1条回答
  • 2021-01-25 02:31

    I have no experience in Grails whatsoever, but from a pure Jersey standpoint, look at what you got here

    @Path('{id}')
    @GET
    ProductResource getResource(@PathParam('id') Long id) {
    

    This is resource method (endpoint). So the ProductsResource will be treated as the response body, just like any other resource method.

    You seem to be trying to use the sub-resource locator functionality, forwarding to the ProductsResource class. For that to work, the sub-resource locator (getResource) should not have an @HttpMethod annotation. That's one of the factors that differentiates a resource method from a sub-resource locator.

    So just remove the @GET from the getResource method. The @GET is already established by the read() method in the ProductsResource, which is what will be called.

    • For more information, see the documentation for Sub-Resource Locators
    0 讨论(0)
提交回复
热议问题