Commit 33db460e by Patryk Czarnik

prefix i sufix

parent 60733e8c
......@@ -25,14 +25,14 @@ public class AlternatywneProdukty2 {
TypedQuery<Product> query = em.createNamedQuery("Product.findAll", Product.class);
List<Product> products = query.getResultList();
model.addAttribute("products", products);
return "/WEB-INF/templates/products.jsp";
return "products";
}
@GetMapping("/products/{id}")
public String oneProduct(Model model, @PathVariable int id) {
Product product = em.find(Product.class, id);
model.addAttribute("product", product);
return "/WEB-INF/templates/product.jsp";
return "product";
}
}
......@@ -12,7 +12,7 @@ public class RootController {
@RequestMapping("/")
public String index() {
return "/WEB-INF/templates/index.jsp";
return "index";
}
@RequestMapping("/hello")
......@@ -25,9 +25,10 @@ public class RootController {
public String ktoraGodzina(Model model) {
LocalDateTime dt = LocalDateTime.now();
model.addAttribute("dt", dt);
return "/WEB-INF/templates/pokaz_czas.jsp";
return "pokaz_czas";
// Pliki JSP umieszczamy w projekcie w src/main/webapp a nie w templates
// Tu docelowo będzie to /WEB-INF/templates :-)
// ale nie musimy pisać pełnej ścieżki w return, bo mamy to skonfigurowane w prefix/suffix
}
}
spring.datasource.url=jdbc:postgresql://localhost/sklep
spring.datasource.username=kurs
spring.datasource.password=abc123
spring.mvc.view.prefix=/WEB-INF/templates/
spring.mvc.view.suffix=.jsp
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