Commit 89857245 by Patryk Czarnik

Obsługa JSP

parent 2a812946
......@@ -55,6 +55,16 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<!-- dopisane zależności, aby działało JSP -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
<dependency>
<groupId>jakarta.servlet.jsp.jstl</groupId>
<artifactId>jakarta.servlet.jsp.jstl-api</artifactId>
</dependency>
</dependencies>
<build>
......
package sklep.controller;
import java.time.LocalDateTime;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -13,4 +16,11 @@ public class RootController {
return "Hello world";
}
@GetMapping("/time")
public String ktoraGodzina(Model model) {
LocalDateTime now = LocalDateTime.now();
model.addAttribute("dt", now);
return "pokaz_czas.jsp";
}
}
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Pokaż czas</title>
</head>
<body>
<div>Bieżący czas: <strong>${dt}</strong></div>
</body>
</html>
\ No newline at end of file
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