Angular 返回http 400状态代码无效

Angular 返回http 400状态代码无效,angular,http,Angular,Http,每一个互联网页面都说这行代码 return new ResponseEntity<Customer>(HttpStatus.BAD_REQUEST); 返回新的响应属性(HttpStatus.BAD_请求); 返回错误代码400,但当我强制它时,我得到“405方法不允许”。 为什么? @PutMapping(value=“/rest/customer/{id}”) 公共对象updateCustomer(@PathVariable(name=“id”)长id, @请求主体(客户){

每一个互联网页面都说这行代码

return new ResponseEntity<Customer>(HttpStatus.BAD_REQUEST);
返回新的响应属性(HttpStatus.BAD_请求);
返回错误代码400,但当我强制它时,我得到“405方法不允许”。 为什么?

@PutMapping(value=“/rest/customer/{id}”)
公共对象updateCustomer(@PathVariable(name=“id”)长id,
@请求主体(客户){
if(id!=customer.getId()){
返回新的响应属性(HttpStatus.BAD_请求);
}否则{

您使用的是什么框架?angular和httprequests with ARCwhat not allowed可能是使用GET而不是POST(方法)调用页面。如果您的fmwk限制为PUT,您将永远不会执行返回的
,fmwk将退出405。
@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 {