summer_programmer 2018-03-19 06:25 采纳率: 0%
浏览 3059
已结题

向后台发送请求, 数据增加成功,后台向前端返回值为显示失败, 不知道是什么原因

这是我的后台代码:

   @PostMapping("/certifications")
    @Timed
    public ResponseEntity<Certification> createCertification(@RequestBody Certification certification) throws URISyntaxException {
        log.debug("REST request to save Certification : {}", certification);
        if (certification.getId() != null) {
            throw new BadRequestAlertException("A new certification cannot already have an ID", ENTITY_NAME, "idexists");
        }
        log.info("certification的id {}", certification.getId());
        Certification result = certificationRepository.save(certification);
        log.info("save 后的certifications {}", result.getId());
        System.out.println("/api/certifications/" + result.getId());
        System.out.println(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()));
        return ResponseEntity.created(new URI("/api/certifications/" + result.getId()))
            .headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
            .body(result);
    }

这是我前端代码:


 this.certification.type = '身份证';
    this.certification.isverify = '未审核';
    this.certification.userId = this.user.id;
    console.log("进入examine()");
    console.log(this.certification);
    this.isSaving = true;
    if (this.certification.id !== undefined) {
      this.subscribeToSaveResponse(
        this.certificationProvider.update(this.certification));
    } else {
      this.subscribeToSaveResponse(
        this.certificationProvider.create(this.certification));
    }
    console.log("实名认证完成");


  create(certification: Certification): Observable<Certification> {
    const copy = this.convert(certification);
    return this.http.post(this.resourceUrl, copy).map((res: Response) => {
      console.log("Response 的"+res.json());
      const jsonResponse = res.json();
      console.log("jsonResponse 的"+jsonResponse);
      return this.convertItemFromServer(jsonResponse);
    });
  }

    private  subscribeToSaveResponse(result: Observable<Certification>) {
  //noinspection TypeScriptUnresolvedVariable
  console.log("subscribeToSaveResponse  里的 result"+result);
  result.subscribe((res: Certification) =>
    this.onSaveSuccess(res), (res: Response) => this.onSaveError());
}

private onSaveSuccess(result: Certification) {
  this.event.publish('carListModification', 'OK');
  this.isSaving = false;
  this.view.dismiss(result);
}

private onSaveError() {
  this.isSaving = false;
  console.log("失败");
}
  • 写回答

3条回答 默认 最新

  • 神牛步行3 2018-03-19 07:03
    关注

    调试,是否走到了方法最后一行;

    评论

报告相同问题?

悬赏问题

  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作