Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230617
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
javab_20230617
Commits
a32fb303
Commit
a32fb303
authored
Jul 29, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Obsługa JSP
parent
73a26765
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
pom.xml
PC27-SklepSpring/pom.xml
+22
-0
RootController.java
...Spring/src/main/java/sklep/controller/RootController.java
+4
-3
show_time.jsp
PC27-SklepSpring/src/main/webapp/show_time.jsp
+18
-0
No files found.
PC27-SklepSpring/pom.xml
View file @
a32fb303
...
@@ -46,6 +46,28 @@
...
@@ -46,6 +46,28 @@
<artifactId>
spring-boot-starter-test
</artifactId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
<scope>
test
</scope>
</dependency>
</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>
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>
<!-- https://jakarta.ee/specifications/tags/3.0/jakarta-tags-spec-3.0.html -->
<!-- Dla Spring Boot 2.x to była właściwa zależność dla JSTL:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
-->
</dependencies>
</dependencies>
<build>
<build>
...
...
PC27-SklepSpring/src/main/java/sklep/controller/RootController.java
View file @
a32fb303
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
;
...
@@ -15,10 +16,10 @@ public class RootController {
...
@@ -15,10 +16,10 @@ public class RootController {
}
}
@GetMapping
(
"/time"
)
@GetMapping
(
"/time"
)
@ResponseBody
public
String
currentTime
(
Model
model
)
{
public
String
currentTime
()
{
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
return
now
.
toString
();
model
.
addAttribute
(
"dt"
,
now
);
return
"show_time.jsp"
;
}
}
}
}
PC27-SklepSpring/src/main/webapp/show_time.jsp
0 → 100644
View file @
a32fb303
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<!DOCTYPE html>
<html>
<head>
<title>
Show time
</title>
</head>
<body>
<h1>
Bieżący czas
</h1>
<p>
Bieżący czas: ${dt}
</p>
<h3>
Wybrane pola:
</h3>
<ul>
<li>
rok:
<strong>
${dt.year}
</strong></li>
<li>
dzień roku:
<strong>
${dt.dayOfYear}
</strong></li>
<li>
sekunda:
<strong>
${dt.second}
</strong></li>
</ul>
<p>
za dwa tygodnie będzie: ${dt.toLocalDate().plusWeeks(2)}
</p>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment