Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20240528-BJava
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
20240528-BJava
Commits
d5b3991f
Commit
d5b3991f
authored
Jun 26, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
przykład PathVariable
parent
95d9b113
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
6 deletions
+8
-6
ParametryController.java
...ring/src/main/java/alx/aplikacja/ParametryController.java
+8
-6
No files found.
PC32-Spring/src/main/java/alx/aplikacja/ParametryController.java
View file @
d5b3991f
package
alx
.
aplikacja
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.*
;
import
jakarta.servlet.http.HttpServletRequest
;
...
...
@@ -40,7 +36,13 @@ public class ParametryController {
// Parametry z adnotacją @RequestParam są domyślnie obowiązkowe. Aby był opcjonalny,
// trzeba wpisać required=false (wtedy brak parametru = null)
// lub podać defaultValue.
@GetMapping
(
"/path/{a}/{b}"
)
@ResponseBody
public
String
parametrPath
(
@PathVariable
String
a
,
@PathVariable
(
"b"
)
String
drugi
)
{
return
"a = "
+
a
+
", b = "
+
drugi
;
}
// Wpisując do własnych metod parametry specjalnych typów, albo używając specjalnych adnotacji,
// możemy uzyskać dostęp do różnych klas narzędziowych serwera lub informacji związanych z zapytaniem.
@GetMapping
(
path
=
"/techniczne"
,
produces
=
"text/plain;charset=UTF-8"
)
...
...
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