コード例 #1
0
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
  public ModelAndView getComment(@PathVariable("id") Long id) {
    ModelAndView modelAndView = new ModelAndView("comment");

    for (SavedComment comment : commentsService.getComments()) {
      if (id.longValue() == comment.id) {
        modelAndView.addObject("comment", CommentModel.fromComment(comment));
      }
    }

    return modelAndView;
  }
コード例 #2
0
 @RequestMapping(method = RequestMethod.GET)
 public CommentsModel getComments() {
   List<SavedComment> comments = commentsService.getComments();
   return CommentsModel.fromList(comments);
 }