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.