Wie rufe ich die Post-Methode mit der Annotation @Pathvariable in Spring Boot auf?Java

Java-Forum
Guest
 Wie rufe ich die Post-Methode mit der Annotation @Pathvariable in Spring Boot auf?

Post by Guest »

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).

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post