Spring 控制台显示错误,如图所示,需要将其清除

Spring 控制台显示错误,如图所示,需要将其清除,spring,angular5,Spring,Angular5,请看上图。我所需要的就是消除控制台显示的错误。该图像不在我的本地目录中,我通过显示一些其他图像在ui中管理了该案例,但控制台仍显示此错误。有人能解决这个问题吗。只需要去掉404。任何帮助都将不胜感激 Java代码: API: @GetMapping(“/files/{filename:.+}”) @应答器 公共响应属性getFile(@PathVariable字符串文件名){ 如果(文件名!=null){ 资源文件=customerController.loadFile(文件名); 如果(文件!

请看上图。我所需要的就是消除控制台显示的错误。该图像不在我的本地目录中,我通过显示一些其他图像在ui中管理了该案例,但控制台仍显示此错误。有人能解决这个问题吗。只需要去掉404。任何帮助都将不胜感激

Java代码: API:

@GetMapping(“/files/{filename:.+}”)
@应答器
公共响应属性getFile(@PathVariable字符串文件名){
如果(文件名!=null){
资源文件=customerController.loadFile(文件名);
如果(文件!=null){
返回ResponseEntity.ok()
.header(HttpHeaders.CONTENT\u处置,“附件;文件名=\”“+文件.getFilename()+”\“”)
.机构(档案);
}否则{
return ResponseEntity.ok().header(HttpHeaders.CONTENT\u处置,“附件;文件名=\”)
.正文(空);
}
}否则{
return ResponseEntity.ok().header(HttpHeaders.CONTENT\u处置,“附件;文件名=\”)
.正文(空);
}
}
控制器:
//客户徽标图像上传相关api
公共资源加载文件(字符串文件名){
试一试{
如果(文件名!=null){
Path rootLocation=Path.get(this.customerLogoPath);
路径文件=rootLocation.resolve(文件名);
Resource Resource=newurlresource(file.toUri());
//System.out.println(资源);
if(resource.exists()&&resource.isReadable()){
返回资源;
}否则{
返回null;
}
}否则{
返回null;
}
}捕获(格式错误){
抛出新的RuntimeException(“失败!”);
}
}
代码的角度方面:

组件技术

getLogos(customer){

      let fileName = customer.customerLogoPath;
      //console.log(fileName);
      if(fileName != null && fileName != undefined && fileName != 'null'){
        //imageget
          this.http.get(this.apiEndPoint+""+fileName)
          .map( res => JSON.parse(JSON.stringify(res)))
          .catch(error => Observable.throw(error))
          .subscribe(
            image => {
              //console.log(image);
            },
            error => {
              //  console.log(error);
              if(error.status !== 404) {
                if(error.url !== null && error.url != "" && !error.url.includes('null')){

                  customer.customerLogoPath = error.url;
                  //console.log(error.url);
                }else{
                  customer.customerLogoPath  = '/assets/images/no-img.png';
                }
              }

            })
      }else{
        customer.customerLogoPath  = '/assets/images/no-img.png';
      }

  }


Component.html:


<div class="row">
                                                            <div class="box-ctn-img col-3 mx-auto text-center"  *ngIf = "customer.customerLogoPath == null && customer.customerLogoPath == undefined">
                                                                <img  src="/assets/images/no-img.png" class="rounded mx-auto d-block img-fluid">
                                                            </div>
                                                            <div class="box-ctn-img col-3 mx-auto text-center" style="margin-right: 25px;" *ngIf = "customer.customerLogoPath !== null && customer.customerLogoPath !== undefined">
                                                                    <img  src ="{{customer?.customerLogoPath}}" class="rounded mx-auto d-block img-fluid">
                                                            </div>

                                                            <div class="box-ctn-dic col-9">
                                                                <h4>[ {{customer.customerCode}} ] -
                                                                    <span>{{customer.customerName}}</span>
                                                                </h4>
                                                                <h3>
                                                                    <span>{{customer.defaultWarehouse?.name}}</span>
                                                                </h3>
                                                                <h3>
                                                                    <span>{{customer.dept?.deptName}}</span>
                                                                </h3>
                                                            </div>
                                                        </div>
getLogos(客户){
让fileName=customer.customerLogoPath;
//log(文件名);
如果(fileName!=null&&fileName!=undefined&&fileName!=“null”){
//imageget
this.http.get(this.apidentpoint+“”+文件名)
.map(res=>JSON.parse(JSON.stringify(res)))
.catch(错误=>Observable.throw(错误))
.订阅(
图像=>{
//console.log(图像);
},
错误=>{
//console.log(错误);
if(error.status!==404){
if(error.url!==null&&error.url!=''&&&!error.url.includes('null')){
customer.customerLogoPath=error.url;
//log(error.url);
}否则{
customer.customerLogoPath='/assets/images/no img.png';
}
}
})
}否则{
customer.customerLogoPath='/assets/images/no img.png';
}
}
Component.html:
[{{customer.customerCode}}]-
{{customer.customerName}
{{customer.defaultWarehouse?.name}
{{客户部门?.deptName}

谢谢

好吧,停止请求这些图像,你就不会有这些404了。您发布了0行代码,所以我们只能这么说。谢谢!我已经添加了相关代码..请看一下@JBNizet
getLogos(customer){

      let fileName = customer.customerLogoPath;
      //console.log(fileName);
      if(fileName != null && fileName != undefined && fileName != 'null'){
        //imageget
          this.http.get(this.apiEndPoint+""+fileName)
          .map( res => JSON.parse(JSON.stringify(res)))
          .catch(error => Observable.throw(error))
          .subscribe(
            image => {
              //console.log(image);
            },
            error => {
              //  console.log(error);
              if(error.status !== 404) {
                if(error.url !== null && error.url != "" && !error.url.includes('null')){

                  customer.customerLogoPath = error.url;
                  //console.log(error.url);
                }else{
                  customer.customerLogoPath  = '/assets/images/no-img.png';
                }
              }

            })
      }else{
        customer.customerLogoPath  = '/assets/images/no-img.png';
      }

  }


Component.html:


<div class="row">
                                                            <div class="box-ctn-img col-3 mx-auto text-center"  *ngIf = "customer.customerLogoPath == null && customer.customerLogoPath == undefined">
                                                                <img  src="/assets/images/no-img.png" class="rounded mx-auto d-block img-fluid">
                                                            </div>
                                                            <div class="box-ctn-img col-3 mx-auto text-center" style="margin-right: 25px;" *ngIf = "customer.customerLogoPath !== null && customer.customerLogoPath !== undefined">
                                                                    <img  src ="{{customer?.customerLogoPath}}" class="rounded mx-auto d-block img-fluid">
                                                            </div>

                                                            <div class="box-ctn-dic col-9">
                                                                <h4>[ {{customer.customerCode}} ] -
                                                                    <span>{{customer.customerName}}</span>
                                                                </h4>
                                                                <h3>
                                                                    <span>{{customer.defaultWarehouse?.name}}</span>
                                                                </h3>
                                                                <h3>
                                                                    <span>{{customer.dept?.deptName}}</span>
                                                                </h3>
                                                            </div>
                                                        </div>