Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_weekendowa_20221008
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_weekendowa_20221008
Commits
1a485376
Commit
1a485376
authored
Nov 27, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
przykładu użycia Spring Security Tags
parent
205094b0
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
1 deletions
+22
-1
pom.xml
PC30-SklepSpring/pom.xml
+4
-0
customer.jsp
...klepSpring/src/main/webapp/WEB-INF/templates/customer.jsp
+5
-0
customers.jsp
...lepSpring/src/main/webapp/WEB-INF/templates/customers.jsp
+8
-1
products.jsp
...klepSpring/src/main/webapp/WEB-INF/templates/products.jsp
+5
-0
No files found.
PC30-SklepSpring/pom.xml
View file @
1a485376
...
...
@@ -66,6 +66,10 @@
<groupId>
javax.servlet
</groupId>
<artifactId>
jstl
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.security
</groupId>
<artifactId>
spring-security-taglibs
</artifactId>
</dependency>
</dependencies>
<build>
...
...
PC30-SklepSpring/src/main/webapp/WEB-INF/templates/customer.jsp
View file @
1a485376
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"s"
uri=
"http://www.springframework.org/tags"
%
>
<
%@
taglib
prefix=
"sec"
uri=
"http://www.springframework.org/security/tags"
%
>
<!DOCTYPE html>
<html>
<head>
...
...
@@ -19,7 +20,11 @@
<tr><th>
Adres:
</th><td>
${customer.address}
</td></tr>
<tr><th>
Miasto:
</th><td>
${customer.postalCode} ${customer.city}
</td></tr>
</table>
<sec:authorize
access=
"hasRole('manager')"
>
<c:url
var=
"adres_do_edycji"
value=
"/customers/${customer.customerEmail}/edit"
/>
<div
class=
"action"
><a
href=
"${adres_edycji}"
>
Edytuj
</a></div>
</sec:authorize>
</body>
</html>
PC30-SklepSpring/src/main/webapp/WEB-INF/templates/customers.jsp
View file @
1a485376
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"s"
uri=
"http://www.springframework.org/tags"
%
>
<
%@
taglib
prefix=
"sec"
uri=
"http://www.springframework.org/security/tags"
%
>
<!DOCTYPE html>
<
%
--
W
tym
pliku
u
ż
ywam
tag
ó
w
c:url
do
generowania
adres
ó
w
,
kt
ó
re
s
ą
poprawne
niezale
ż
nie
od
miejsca
zdeployowania
aplikacji
.
Oboj
ę
tnie
,
czy
aplikacja
dzia
ł
abezpo
ś
rednio
pod
adresem
localhost:8080
/
,
czy
w
jakim
ś
podkatalogu
(
ma
niepusty
"
context-path
"),
...
...
@@ -28,13 +29,19 @@ Obojętnie, czy aplikacja działabezpośrednio pod adresem localhost:8080/ , czy
<td>
${customer.address}
</td>
<td>
${customer.postalCode} ${customer.city}
</td>
<td>
<sec:authorize
access=
"hasRole('manager')"
>
<c:url
var=
"adres_do_edycji"
value=
"/customers/${customer.customerEmail}/edit"
/>
<td
class=
"action"
><a
href=
"${adres_do_edycji}"
>
Edytuj
</a></td>
<div
class=
"action"
><a
href=
"${adres_do_edycji}"
>
Edytuj
</a></div>
</sec:authorize>
</td>
</tr>
</c:forEach>
</table>
<sec:authorize
access=
"hasRole('manager')"
>
<c:url
var=
"adres_new"
value=
"/customers/new"
/>
<div
class=
"action"
><a
href=
"${adres_new}"
>
Dodaj nowego klienta
</a></div>
</sec:authorize>
</body>
</html>
PC30-SklepSpring/src/main/webapp/WEB-INF/templates/products.jsp
View file @
1a485376
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"sec"
uri=
"http://www.springframework.org/security/tags"
%
>
<!DOCTYPE html>
<html>
<head>
...
...
@@ -29,12 +30,16 @@
<p>
Towar
<a
href=
"/products/${product.productId}"
class=
"product-name"
>
${product.productName}
</a></p>
<p>
Cena:
<span
class=
"product-price"
>
${product.price}
</span></p>
<p
class=
"product-description"
>
${product.description}
</p>
<sec:authorize
access=
"hasRole('manager')"
>
<div
class=
"action"
><a
href=
"/products/${product.productId}/edit"
>
Edytuj
</a></div>
</sec:authorize>
<div
class=
"action"
><a
href=
"/products/${product.productId}/add-to-basket"
>
Dodaj do koszyka
</a></div>
</div>
</c:forEach>
<sec:authorize
access=
"hasRole('manager')"
>
<div><a
href=
"/products/new"
>
Dodaj nowy produkt
</a></div>
</sec:authorize>
<div><a
href=
"/"
>
Wróć na stronę główną
</a></div>
</body>
...
...
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