Commit 89857245 by Patryk Czarnik

Obsługa JSP

parent 2a812946
...@@ -55,6 +55,16 @@ ...@@ -55,6 +55,16 @@
<artifactId>spring-security-test</artifactId> <artifactId>spring-security-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </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> </dependencies>
<build> <build>
......
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;
...@@ -12,5 +15,12 @@ public class RootController { ...@@ -12,5 +15,12 @@ public class RootController {
public String hello() { public String hello() {
return "Hello world"; 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