Commit 5c9f4b1f by Patryk Czarnik

pokaż czas

parent dfb125f7
package sklep.controller; package sklep.controller;
import java.time.LocalDateTime;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
...@@ -16,4 +19,10 @@ public class RootController { ...@@ -16,4 +19,10 @@ public class RootController {
public String hello() { public String hello() {
return "Hello Spring!"; return "Hello Spring!";
} }
@GetMapping("/czas")
public String odczytajCzasJsp(Model model) {
model.addAttribute("dt", LocalDateTime.now());
return "wyswietl_czas";
}
} }
<%@page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Która godzina</title>
</head>
<body>
<h1>Wyświetlanie czasu</h1>
<p>Teraz jest: <strong>${dt}</strong></p>
<p>Do 17 brakuje ${17 - dt.hour} godzin.</p>
</body>
</html>
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