Commit 9258a181 by Patryk Czarnik

Dodanie obsługi JSP

parent e9377d0f
...@@ -68,6 +68,20 @@ ...@@ -68,6 +68,20 @@
<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>
<dependency>
<groupId>org.glassfish.web</groupId>
<artifactId>jakarta.servlet.jsp.jstl</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package sklep.controller; package sklep.controller;
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;
import java.time.LocalDateTime;
@Controller @Controller
public class RootController { public class RootController {
...@@ -12,4 +15,10 @@ public class RootController { ...@@ -12,4 +15,10 @@ public class RootController {
public String hello() { public String hello() {
return "Hello world"; return "Hello world";
} }
@GetMapping("/czas")
public String odczytajCzasJsp(Model model) {
model.addAttribute("dt", LocalDateTime.now());
return "wyswietl_czas.jsp";
}
} }
<%@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>
</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