angular - 来自 http 服务的空响应
问题描述
我收到来自 http 服务的空响应。我在 Spring Boot 中的服务方法正确返回响应数据,但在角度上它显示为空。
这是我的角度方法:
this.httpService.findById(UrlDetails.$getPymentInfoResponseUrl, request).subscribe((response) => {
debugger;
if (response.responseCode == 200) {
let PaymentData=response.responseData;
let Payment = response.responseData;
if(this.payment.paymentMethod == 'CREDIT_CARD'){
this.jobPaymentForm.get('paymentMethod').setValue('CREDIT_CARD');
this.jobPaymentForm.get('cardHolderName').setValue(this.payment.creditCardPayment.cardHolderName);
this.jobPaymentForm.get('cardNumber').setValue(this.payment.creditCardPayment.cardNumber);
this.jobPaymentForm.get('expirationMonth').setValue(this.payment.creditCardPayment.expirationMonth);
this.jobPaymentForm.get('expirationYear').setValue(this.payment.creditCardPayment.expirationYear);
this.paymentType1 = false;
this.paymentType2 = true;
this.paymentMehodSelect=false;
}
这是http服务:
findById(url:string, value:any):Observable < any > {
let headers = new Headers( {'Content-Type':'application/json'});
let options = new RequestOptions( {headers:headers });
return this.http.post(url, value, options).map(this.extractData);
}
这是将请求的数据发送回角度的弹簧启动方法:
public ResponseEntity<BaseEntitiesResponse<Payment>> getPaymentInfo(Payment payment) {
System.out.println("---->"+payment);
logger.debug("entering inside getPaymentInfo method for {} ",payment.getClientId());
logger.debug("entering inside getPaymentInfo method for {} ",payment.getOrderId());
BaseEntitiesResponse<Payment> findPaymentResponse = new BaseEntitiesResponse<>();
if (payment == null) {
findPaymentResponse.setInvalidRequestParamResponse();
return new ResponseEntity<BaseEntitiesResponse<Payment>>(findPaymentResponse, HttpStatus.OK);
}
List<Payment> record = paymentRepository.findPaymentMethodByClientId(payment.getClientId());
List<Payment> record1 = paymentRepository.findPaymentByClientIdAndOrderId(payment.getClientId(),payment.getOrderId());
logger.debug("Record object : ",record1);
if (record == null || record.isEmpty()) {
findPaymentResponse.setRecordNotFoundResponse();
return new ResponseEntity<BaseEntitiesResponse<Payment>>(findPaymentResponse, HttpStatus.OK);
}
findPaymentResponse.setRecordFoundResponse(record1);
return new ResponseEntity<BaseEntitiesResponse<Payment>>(findPaymentResponse, HttpStatus.OK);
}
此方法返回正确的响应。
解决方案
推荐阅读
- c# - 无法在 MVC 5 中检查授权和使用会话超时
- javascript - 尝试使用 Function 对象使用尾递归
- javascript - 有没有办法使用 Three.js 将 3D 模型导出为 PNG 图像
- shell - 有没有一种方法可以让我在另一台服务器上使用 shell 脚本访问、使用和操作来自一台服务器的文件>
- firebase - 如何优化每次应用启动时的 Firestore 读取
- python - 在 python 中安装任何包时出错:HTTPError: 404 Client Error: Not Found for url
- mysql - MySQL/MariaDB 更新计数器组按
- protocol-buffers - 从 protobuf 生成的 Java 类有编译错误
- c# - linq:如何检查一个属性的值是否存在
- javascript - 如何让画布动画代码与多个元素一起使用?