Commit 66557678 by Patryk Czarnik

sortowanie rekordów

parent 19d90a5f
...@@ -4,6 +4,7 @@ import java.util.List; ...@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
...@@ -19,7 +20,7 @@ public class ProductController { ...@@ -19,7 +20,7 @@ public class ProductController {
@GetMapping("/products") @GetMapping("/products")
public String readAllProducts(Model model) { public String readAllProducts(Model model) {
List<Product> products = productRepository.findAll(); List<Product> products = productRepository.findAll(Sort.by("productId"));
model.addAttribute("products", products); model.addAttribute("products", products);
return "products"; return "products";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment