Commit 8c3fe5f8 by Patryk Czarnik

Zalezności dot. JSP i pierwszy przykład szablonu

parent 8844e794
......@@ -55,6 +55,18 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Dodatkowe zależności, aby używać JSP w Springu -->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<!-- numer wersji będzie automatycznie nadany przez Spring Boot -->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</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.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
......@@ -17,5 +20,12 @@ public class RootController {
public String hello() {
return "Hello Spring";
}
@RequestMapping(path="/time", produces="text/plain")
public String ktoraGodzina(Model model) {
LocalDateTime dt = LocalDateTime.now();
model.addAttribute("dt", dt);
return "wyswietl_czas.jsp";
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Która godzina (JSP)</title>
</head>
<body>
<h1>Która godzina (JSP)</h1>
<p>Teraz jest godzina <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