小编Gor*_*jic的帖子

Angular:当资产文件夹发生更改时防止自动重新编译

我正在尝试在 Angular 项目的资产中下载由 Spring Boot 生成的文件。当我从 Angular 服务调用 Spring API 时,Angular CLI 在 Assets Angular 文件夹中创建文件后重新编译项目,然后在从 Spring Boot API 获取响应之前重新加载页面。

我尝试通过多种方式从 Angular 调用 Spring Boot API:

  • 在我的组件的 ngOnInit() 中调用 api
  • 在我的组件的构造函数中调用 api
  • 在单独的函数中调用 api
  • 在下载功能中使用异步等待

我不知道如何继续

弹簧靴

 @GetMapping(path = "/downloads/{fileId}", produces = "application/json")
    @ResponseBody
    public ResponseEntity<String> download(@PathVariable String fileId){
        Gson gson = createGson();

        List<com.bioimis.blp.entity.File> fileById;

        try {
            fileById = fileRepository.findFileById(fileId);

        } catch (Exception e) {
            logger.error(e.getMessage());
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
        }

        if (fileById.isEmpty()) {
            logger.error(fileId + " not found");
            return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
        } …
Run Code Online (Sandbox Code Playgroud)

html livereload spring-boot angular

7
推荐指数
1
解决办法
3443
查看次数

标签 统计

angular ×1

html ×1

livereload ×1

spring-boot ×1