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
161646de
Commit
161646de
authored
Oct 19, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kalkulator - obsługa różnych działań
parent
856db191
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
KalkulatorController.java
.../src/main/java/com/example/demo/KalkulatorController.java
+9
-2
kalkulator.html
PC26-Spring/src/main/resources/templates/kalkulator.html
+6
-2
No files found.
PC26-Spring/src/main/java/com/example/demo/KalkulatorController.java
View file @
161646de
...
@@ -16,8 +16,15 @@ public class KalkulatorController {
...
@@ -16,8 +16,15 @@ public class KalkulatorController {
}
}
@PostMapping
@PostMapping
public
String
rozmowaPost
(
Integer
liczba1
,
Integer
liczba2
,
String
operacja
,
Model
model
)
{
public
String
rozmowaPost
(
Long
liczba1
,
Long
liczba2
,
String
operacja
,
Model
model
)
{
Integer
wynik
=
liczba1
+
liczba2
;
Long
wynik
=
switch
(
operacja
)
{
case
"+"
->
liczba1
+
liczba2
;
case
"-"
->
liczba1
-
liczba2
;
case
"*"
->
liczba1
*
liczba2
;
case
"/"
->
liczba1
/
liczba2
;
default
->
0L
;
};
model
.
addAttribute
(
"wynik"
,
wynik
);
model
.
addAttribute
(
"wynik"
,
wynik
);
return
"kalkulator.html"
;
return
"kalkulator.html"
;
}
}
...
...
PC26-Spring/src/main/resources/templates/kalkulator.html
View file @
161646de
...
@@ -21,8 +21,12 @@
...
@@ -21,8 +21,12 @@
<button>
Oblicz
</button>
<button>
Oblicz
</button>
</form>
</form>
<div
class=
"wynik"
>
<div
th:if=
"${wynik != null}"
class=
"wynik"
>
[[${wynik}]]
<span
th:text=
"${param.liczba1}"
>
2
</span>
<span
th:text=
"${param.operacja}"
>
+
</span>
<span
th:text=
"${param.liczba2}"
>
3
</span>
=
<strong
th:text=
"${wynik}"
>
5
</strong>
</div>
</div>
</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