Commit d5b3991f by Patryk Czarnik

przykład PathVariable

parent 95d9b113
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;
......@@ -41,6 +37,12 @@ public class ParametryController {
// 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")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment