title: Converting List of objects into pages in spring
body: <p>I am trying to get page with a number of items in each page. For some reason, this method returns the complete list instead of page of 5 items.</p>
  
  <pre><code>public Page&lt;Item&gt; searchPagedCategoryByName(@RequestParam String name) 
  {
      Category category;
      category = categoryRepository.findCategoryByCategoryName(name);
      List&lt;Item&gt; items = category.getItems();
  
      Pageable pageable = PageRequest.of(0,5);
      Page&lt;Item&gt; page = new PageImpl&lt;Item&gt;(items, pageable, items.size());
      return page;
  }
  </code></pre>