Jhonathan Martini
Jhonathan Martini

Reputation: 13

No mapping for DELETE

  this is the implementation if the Http Delete method where i'm trying to delete this object 
  "vente" by it's id, and as seen below the mapping is provided for the DELETE method.
    

       @DeleteMapping(value = ConstantController.VENTE+"/{venteId}")
       public ResponseEntity<?> deleteVente(@PathVariable BigInteger venteId){
           venteService.deleteVente(venteId);
       return new ResponseEntity<Void>(HttpStatus.OK);
       }

       
     this is the uri for accessing the the service:
     http://localhost:8080/stock-ws/vente/1

     this what i get in the server tomcat log when i send the http request with the delete 
     method:
     2021-10-17 22:18:29.258[0;39m [32m INFO[0;39m [35m3848[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.a.c.c.C.[Tomcat].[localhost].[/]      [0;39m [2m:[0;39m Initializing Spring DispatcherServlet 'dispatcherServlet'

[2m2021-10-17 22:18:29.258[0;39m [32m INFO[0;39m [35m3848[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Initializing Servlet 'dispatcherServlet' [2m2021-10-17 22:18:29.262[0;39m [32m INFO[0;39m [35m3848[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.DispatcherServlet [0;39m [2m:[0;39m Completed initialization in 4 ms [2m2021-10-17 22:18:29.289[0;39m [33m WARN[0;39m [35m3848[0;39m [2m---[0;39m [2m[nio-8080-exec-1][0;39m [36mo.s.web.servlet.PageNotFound [0;39m [2m:[0;39m No mapping for DELETE /stock-ws/vente/1

     couldn't spot the bug any help will be apreciated!

Upvotes: 0

Views: 553

Answers (1)

Murat Kara
Murat Kara

Reputation: 831

Maybe you can try this;

@RestController
@RequestMapping("/stock-ws/vente")
class TestController(){
    @DeleteMapping("{venteId}")
    public ResponseEntity<?> deleteVente(@PathVariable BigInteger venteId){
        venteService.deleteVente(venteId);
    return new ResponseEntity<Void>(HttpStatus.OK);
    }
}

Upvotes: 0

Related Questions