0

我有这个端点调用我的服务方法,然后调用我的 repo 类来删除用户,但是当我通过邮递员调用这个端点时,我得到一个请求方法不支持”打印在控制台中,任何帮助将不胜感激

@RequestMapping(value = "/{useId}/delete-user", method = RequestMethod.DELETE)
    public ResponseEntity<String> deleteUser(@PathVariable("userId") String userId){
        ResponseEntity<String> response = null;
        try {
            validate(userId);
            userService.deleteUser(Long.parseLong(userId));
            response = new ResponseEntity<String>(HttpStatus.NO_CONTENT);
        }catch (InputMismatchException e){
            response = new ResponseEntity<String>(HttpStatus.BAD_REQUEST);
        } catch (UserNotFoundException e) {
            response = new ResponseEntity<String>(HttpStatus.NOT_FOUND);
        } catch (AccessDeniedException e) {
            response = new ResponseEntity<String>(HttpStatus.FORBIDDEN);
        }
        return  response;
    }

收到的消息是Request method 'DELETE' not supported

4

1 回答 1

1

里面有错别字@RequestMappinguserid拼写错误。这就是为什么 Spring 没有映射DELETEtodeleteUser方法

于 2015-10-28T15:46:41.200 回答