Exemple #1
0
  @RequestMapping(
      value = "/{year:\\d+}/{month:\\d+}",
      method = {GET, HEAD})
  public String listPublishedPostsForYearAndMonth(
      @PathVariable int year,
      @PathVariable int month,
      @RequestParam(defaultValue = "1", value = "page") int page,
      Model model) {

    Pageable pageRequest = PageableFactory.forLists(page);
    Page<Post> result = service.getPublishedPostsByDate(year, month, pageRequest);
    YearMonth yearMonth = new YearMonth(year, month);
    model.addAttribute("title", "Archive for " + yearMonth.toString("MMMM yyyy"));
    return renderListOfPosts(result, model, "All Posts");
  }