@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; }
@RequestMapping(method = RequestMethod.GET) public CommentsModel getComments() { List<SavedComment> comments = commentsService.getComments(); return CommentsModel.fromList(comments); }