Esempio n. 1
0
  @RequestMapping(
      value = "/{year:\\d+}",
      method = {GET, HEAD})
  public String listPublishedPostsForYear(
      @PathVariable int year,
      @RequestParam(defaultValue = "1", value = "page") int page,
      Model model) {

    Pageable pageRequest = PageableFactory.forLists(page);
    Page<Post> result = service.getPublishedPostsByDate(year, pageRequest);
    model.addAttribute("title", String.format("Archive for %d", year));
    return renderListOfPosts(result, model, "All Posts");
  }
Esempio n. 2
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");
  }