The backend of Angular sending POST request cannot receive parameters.

the front-end code is as follows

    const httpOptions = {
      headers: new HttpHeaders({
        "Content-Type": "application/x-www-form-urlencoded"
      })
    }
    const params = {
        "type": "phone",
        "key": "1234567"
    }
    this.http.post("/bss/verifyCode", params , httpOptions).subscribe();

the backend code is as follows

    @PostMapping
    public ReturnMsg sendVerifyCode(String type, String key) {
        if (PHONE.equals(type)) {
            return service.sendVerifyCodeByPhone(key);
        } else {
            return service.sendVerifyCodeByEmail(key);
        }
    }

the post request test interface constructed with resttemplate or Postman can be used normally, but the parameters cannot be received when calling the interface in the front-end angular environment. The request is accepted correctly, but there are no parameters. In addition, it can also be received by using url to transmit parameters.
the request content sent by the front-end code is as follows

Please give us some advice on what went wrong at the front and rear.

Aug.16,2021
The

problem has been resolved, and the Content-Type of the parameters expected to be received by the front and back end must be the same. @ PostMapping is not x-www-form-urlencoded by default

Menu