Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_dzienna_15_09
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
java_dzienna_15_09
Commits
fa062879
Commit
fa062879
authored
Oct 04, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pierwsze przykłady JSP
parent
fc064b25
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
232 additions
and
0 deletions
+232
-0
pom.xml
PC30-SklepSpring/pom.xml
+11
-0
RootController.java
...Spring/src/main/java/sklep/controller/RootController.java
+17
-0
index.jsp
PC30-SklepSpring/src/main/webapp/index.jsp
+53
-0
pokaz_czas.jsp
PC30-SklepSpring/src/main/webapp/pokaz_czas.jsp
+20
-0
styl.css
PC30-SklepSpring/src/main/webapp/styl.css
+131
-0
No files found.
PC30-SklepSpring/pom.xml
View file @
fa062879
...
@@ -55,6 +55,17 @@
...
@@ -55,6 +55,17 @@
<artifactId>
spring-security-test
</artifactId>
<artifactId>
spring-security-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>
javax.servlet
</groupId>
<artifactId>
jstl
</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
...
...
PC30-SklepSpring/src/main/java/sklep/controller/RootController.java
View file @
fa062879
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.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
...
@@ -8,8 +11,22 @@ import org.springframework.web.bind.annotation.ResponseBody;
...
@@ -8,8 +11,22 @@ import org.springframework.web.bind.annotation.ResponseBody;
public
class
RootController
{
public
class
RootController
{
@RequestMapping
(
"/"
)
@RequestMapping
(
"/"
)
public
String
index
()
{
return
"index.jsp"
;
}
@RequestMapping
(
"/hello"
)
@ResponseBody
@ResponseBody
public
String
hello
()
{
public
String
hello
()
{
return
"Hello world"
;
return
"Hello world"
;
}
}
@RequestMapping
(
"/ktora-godzina"
)
public
String
ktoraGodzina
(
Model
model
)
{
LocalDateTime
dt
=
LocalDateTime
.
now
();
model
.
addAttribute
(
"dt"
,
dt
);
return
"pokaz_czas.jsp"
;
// Pliki JSP umieszczamy w projekcie w src/main/webapp a nie w templates
}
}
}
PC30-SklepSpring/src/main/webapp/index.jsp
0 → 100644
View file @
fa062879
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Aplikacja Sklep Spring
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Spis treści
</h1>
<h2>
Podstawy
</h2>
<ul>
<li><a
href=
"/"
>
Spis treści
</a></li>
<li><a
href=
"/hello"
>
Hello world
</a></li>
<li><a
href=
"/ktora-godzina"
>
Która godzina
</a></li>
</ul>
<h2>
Logowanie
</h2>
<ul>
<li><a
href=
"/login"
>
zaloguj się
</a>
<li><a
href=
"/logout"
>
wyloguj się
</a>
<li><a
href=
"/whoami"
>
sprawdź kim jesteś
</a>
</ul>
<h2>
Katalog produktów
</h2>
<ul>
<li><a
href=
"/products"
>
products
</a>
- wszystkie produkty
</li>
<li><a
href=
"/products/1"
>
products/1
</a>
- jeden produkt
</li>
<li><a
href=
"/products/9"
>
products/9
</a>
- nieistniejący produkt
</li>
<li><a
href=
"/wyszukiwarka"
>
wyszukiwarka
</a></li>
<li><a
href=
"/products/new"
>
nowy produkt
</a></li>
<li><a
href=
"/products/1/edit"
>
edycja produktu
</a></li>
</ul>
<h2>
Edycja klienta
</h2>
<ul>
<li><a
href=
"/customers"
>
lista klientów
</a>
<li><a
href=
"/customers/new"
>
nowy klient
</a>
<li><a
href=
"/customers/ala@example.com/edit"
>
edycja klienta
</a>
</ul>
<h2>
Alternatywne dostępy do bazy danych
</h2>
<ul>
<li><a
href=
"/dodatkowe/sql"
>
Dostęp JDBC
</a>
(wstrzykiwanie DataSource)
</li>
<li><a
href=
"/dodatkowe/jpa"
>
Dostęp Hibernate/JPA
</a>
(wstrzykiwanie EntityManager)
</li>
<li><a
href=
"/dodatkowe/products"
>
products
</a>
(wstrzykiwanie EntityManager)
</li>
<li><a
href=
"/dodatkowe/products/1"
>
jeden produkt
</a></li>
<li><a
href=
"/dodatkowe/by_price?min=1000&max=2900"
>
by price
</a></li>
</ul>
</body>
</html>
PC30-SklepSpring/src/main/webapp/pokaz_czas.jsp
0 → 100644
View file @
fa062879
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Która godzina
</title>
</head>
<body>
<h1>
Która godzina
</h1>
<p>
Teraz jest godzina
<strong>
${dt}
</strong></p>
<h2>
Wybrane pola:
</h2>
<ul>
<li>
rok: ${dt.year}
</li>
<li>
dzień roku: ${dt.dayOfYear}
</li>
</ul>
</body>
</html>
\ No newline at end of file
PC30-SklepSpring/src/main/webapp/styl.css
0 → 100644
View file @
fa062879
@charset
"UTF-8"
;
body
{
background-color
:
#FFFFDD
;
font-family
:
'Arial'
,
sans-serif
;
}
h1
,
h4
{
text-align
:
center
;
}
h2
,
h3
,
h4
{
margin-top
:
0
;
}
.product
{
border
:
solid
2px
blue
;
margin
:
1em
400px
1em
50px
;
padding
:
1em
;
background-color
:
#DDFFDD
;
width
:
800px
;
clear
:
right
;
}
.basket
{
position
:
fixed
;
right
:
0
;
top
:
0
;
width
:
300px
;
height
:
400px
;
background-color
:
white
;
border
:
outset
3px
green
;
padding
:
1em
;
font-size
:
smaller
;
}
.product-name
,
.product-price
{
font-weight
:
bold
;
font-size
:
larger
;
}
.product-description
{
font-style
:
italic
;
}
.error
{
color
:
red
;
border
:
4px
solid
red
;
margin
:
1em
0
;
padding
:
1em
;
background-color
:
white
;
font-weight
:
bold
;
}
.info
{
color
:
green
;
border
:
4px
solid
green
;
margin
:
1em
0
;
padding
:
1em
;
background-color
:
white
;
font-weight
:
bold
;
min-width
:
500px
;
max-width
:
1000px
;
}
#wyszukiwarka
{
background-color
:
#AAEEFF
;
width
:
800px
;
border
:
2px
black
solid
;
margin
:
1em
400px
1em
50px
;
padding
:
1em
;
}
#product-form
{
margin
:
1em
auto
;
padding
:
1em
;
border
:
4px
solid
blue
;
background-color
:
#DDFFFF
;
min-width
:
500px
;
max-width
:
1000px
;
}
#product-form
textarea
{
min-width
:
360px
;
}
.form-error
{
color
:
red
;
font-size
:
smaller
;
}
div
.action
{
font-size
:
smaller
;
font-family
:
'Arial'
,
sans-serif
;
font-weight
:
bold
;
background-color
:
#DDDDDD
;
border
:
2px
#444466
outset
;
padding
:
6px
;
margin
:
4px
auto
4px
4px
;
max-width
:
200px
;
}
.action
:hover
{
background-color
:
#EEEEEE
;
border
:
2px
#4455CC
outset
;
}
.action
:active
{
background-color
:
#EEEEEE
;
border
:
2px
#CC4455
inset
;
}
.action
a
{
display
:
inline-block
;
color
:
inherit
;
text-decoration
:
none
;
width
:
100%
;
}
.action
a
:hover
{
color
:
#0000CC
;
}
.photo
{
display
:
block
;
float
:
right
;
max-width
:
300px
;
max-height
:
200px
;
margin
:
5px
;
}
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