首页 > 解决方案 > 返回 http 400 状态码不起作用

问题描述

每个网页都说这行代码

return new ResponseEntity<Customer>(HttpStatus.BAD_REQUEST);

返回错误代码 400,但是当我强制它时,我得到“405 Method Not Allowed”。为什么?

@PutMapping(value = "/rest/customer/{id}")
        public Object updateCustomer(@PathVariable(name = "id") long id,
                                     @RequestBody Customer customer) {
        if (id != customer.getId()) {
            return new ResponseEntity<Customer>(HttpStatus.BAD_REQUEST);
        } else {

标签: angularhttp

解决方案


推荐阅读