title: Sub-Resources in spring REST
body: <p>I'm trying to build messanger app.</p>
  
  <p>I've to call CommentResource from MessageResource.</p>
  
  <p>I want separate MessageResources and CommentResources.</p>
  
  <p>I'm doing something like this : </p>
  
  <p>MessageResource.java</p>
  
  <pre><code>@RestController
  @RequestMapping("/messages")
  public class MessageResource {
  
      MessageService messageService = new MessageService();
  
      @RequestMapping(value = "/{messageId}/comments")
      public CommentResource getCommentResource() {
          return new CommentResource();
      }
  }
  </code></pre>
  
  <p>CommentResource.java</p>
  
  <pre><code>@RestController
  @RequestMapping("/")
  public class CommentResource {
  
      private CommentService commentService = new CommentService();
  
      @RequestMapping(method = RequestMethod.GET, value="/abc")
      public String test2() {
          return "this is test comment";
      }
  }
  </code></pre>
  
  <p>I want </p>
  
  <p><a href="http://localhost:8080/messages/1/comments/abc" rel="noreferrer">http://localhost:8080/messages/1/comments/abc</a></p>
  
  <p>to return "this is test comment".</p>
  
  <p>Any Idea??</p>
  
  <p>PS: In a simple word, I want to know <code>JAX-RS sub-resource</code> equivalent implementation in <code>spring-rest</code></p>