by Guest » 03 Jan 2025, 04:04
Wie soll ich die Post-Methode mit @PathVariable vom Browser aus aufrufen?
Nach der Suche nach allen Fragen gibt es keine eindeutige Antwort auf diese Frage. Ich möchte keine anderen Anmerkungen verwenden.
Code: Select all
@RestController
@RequestMapping("/api")
public class PlugController {
@PostMapping(value = "/command/{cmd}")
public String command(@PathVariable(value = "cmd") String command) {
return command;
}
}
Aufruf über den Browser wie folgt:
Code: Select all
http://localhost:8080/api/command/on
Fehler:
Code: Select all
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
There was an unexpected error (type=Method Not Allowed, status=405).
Wie soll ich die Post-Methode mit @PathVariable vom Browser aus aufrufen?
Nach der Suche nach allen Fragen gibt es keine eindeutige Antwort auf diese Frage. Ich möchte keine anderen Anmerkungen verwenden.
[code]@RestController
@RequestMapping("/api")
public class PlugController {
@PostMapping(value = "/command/{cmd}")
public String command(@PathVariable(value = "cmd") String command) {
return command;
}
}
[/code]
Aufruf über den Browser wie folgt:
[code]http://localhost:8080/api/command/on
[/code]
Fehler:
[code]Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
There was an unexpected error (type=Method Not Allowed, status=405).
[/code]