Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230928
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_20230928
Commits
59cf756f
Commit
59cf756f
authored
Oct 17, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pierwsze przykłady z JSTL
parent
b0dc1df3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
1 deletions
+49
-1
pom.xml
PC24-Serwlety/pom.xml
+20
-0
PrzykladowyBean.java
PC24-Serwlety/src/main/java/beans/PrzykladowyBean.java
+4
-0
przyklad2.jsp
PC24-Serwlety/src/main/webapp/przyklad2.jsp
+25
-1
No files found.
PC24-Serwlety/pom.xml
View file @
59cf756f
...
@@ -20,6 +20,26 @@
...
@@ -20,6 +20,26 @@
<version>
6.0.0
</version>
<version>
6.0.0
</version>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<dependency>
<groupId>
jakarta.servlet.jsp.jstl
</groupId>
<artifactId>
jakarta.servlet.jsp.jstl-api
</artifactId>
<version>
3.0.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
org.glassfish.web
</groupId>
<artifactId>
jakarta.servlet.jsp.jstl
</artifactId>
<version>
3.0.1
</version>
<scope>
provided
</scope>
</dependency>
<!-- stara klasyczna wersja - tylko dla starszych serwerów. Java EE 8 lub starsze: -->
<!-- <dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
-->
</dependencies>
</dependencies>
<build>
<build>
...
...
PC24-Serwlety/src/main/java/beans/PrzykladowyBean.java
View file @
59cf756f
...
@@ -18,6 +18,10 @@ public class PrzykladowyBean {
...
@@ -18,6 +18,10 @@ public class PrzykladowyBean {
this
.
napis
=
napis
;
this
.
napis
=
napis
;
}
}
public
String
[]
getWords
()
{
return
napis
.
split
(
" "
);
}
public
int
wylosuj
()
{
public
int
wylosuj
()
{
return
random
.
nextInt
(
1000
);
return
random
.
nextInt
(
1000
);
}
}
...
...
PC24-Serwlety/src/main/webapp/przyklad2.jsp
View file @
59cf756f
<
%@
page
import=
"java.time.LocalTime"
%
>
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"jakarta.tags.core"
%
>
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
...
@@ -38,6 +38,30 @@
...
@@ -38,6 +38,30 @@
--
%
>
--
%
>
<
%
--
Biblioteka
tag
ó
w
("
taglib
")
to
jest
zestaw
polece
ń
zapisywanych
w
formie
znacznik
ó
w
w
obr
ę
bie
JSP
.
Te
znaczniki
zawsze
s
ą
poprzedzane
prefiksem
,
np
.
<
c:if
>
....
Tagliby można definiować samodzielnie, ale w 98% przypadków używa się zestawu nazywanego JSTL
"Java Standard Tag Library"
--%>
<h3>
Taglibs
</h3>
<ul>
<c:forEach
var=
"i"
items=
"5,10,15"
>
<li>
${i}
<c:choose>
<c:when
test=
"${i % 2 == 0}"
>
parzyste
</c:when>
<c:otherwise>
nieparzyste
</c:otherwise>
</c:choose>
</li>
</c:forEach>
</ul>
<p>
Słowa napisu:
</p>
<ul>
<c:forEach
var=
"word"
items=
"${obiekt.words}"
>
<li>
${word}
</li>
</c:forEach>
</ul>
</body>
</body>
</html>
</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