简体   繁体   English

如何使用存储在子表中的路径显示图像 - Angular 和 Spring boot

[英]how can I display images using a path stored in a child table- Angular and Spring boot

I'm working on a project where image url is stored in a child table(image) and the image is in a folder.我正在处理一个项目,其中图像 url 存储在子表(图像)中并且图像位于文件夹中。 I can display all images from image table.我可以显示图像表中的所有图像。

<ng-container matColumnDef="location">
      <th mat-header-cell *matHeaderCellDef>IMAGE</th>
      <td mat-cell *matCellDef="let productImage">
        <img
          height="100"
          width="100"
          src="{{ productImage?.location }}"
          class="rounded-circle img-fluid img-thumbnail"
          alt=""
        />
      </td>

But when I try the following, the images are not displayed while other data is accessible through parent–child relationship.但是当我尝试以下操作时,图像不会显示,而其他数据可以通过父子关系访问。 this product.image.name works okay.这个product.image.name工作正常。

<ng-container matColumnDef="location">
          <th mat-header-cell *matHeaderCellDef>Image</th>
          <td mat-cell *matCellDef="let product">
            <img
              height="100"
              width="100"
              src="{{ product.image.location }}"
              alt="{{ product.image.name }}"
              class="rounded-circle img-fluid img-thumbnail"
              alt=""
            />
          </td>
        </ng-container>

To have the images displayed I added image.setLocation(entity.getImage().getLocation());为了显示图像,我添加了image.setLocation(entity.getImage().getLocation()); in my product dto converter.在我的产品 dto 转换器中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Angular 4 在 Spring Boot 中显示存储的图像? - How to display stored images in Spring Boot using Angular 4? 如何使用angular检索路径存储在数据库中的图像? - how can i retrieve images whose path is stored in database using angular? 如何在Spring MVC中显示存储在数据库中的图像 - How display images that stored in database in spring mvc 如何在 Java Spring Boot 中读取文件路径中的文本? - How can I read text in a file path in Java Spring Boot? 如何在 spring 引导 jboss/wildfly 中设置上下文路径? - How can I set context path in spring boot jboss/wildfly? 使用 Spring 引导,如何在新表上创建 2 个实体之间的关系并为其提供额外的列? - Using Spring Boot, how can I create the relationship between 2 entities on a new table and give it extra columns? 如何安全地在Spring Boot Rest控制器中使用“ / images”路径? - How do I use “/images” path in Spring boot Rest controller with security? 如何使用 Spring Boot 在我的 postgres 数据库中创建一个表? - How can I create a table in my postgres db with Spring Boot? Java Spring Boot:项目用IDE Intellji打开时图片保存路径错误,不显示图片 - Java Spring Boot: project saves images in the wrong path and not display images when opening with IDE Intellji 无法在 Angular + Spring Boot 项目中使用 *ngFor 显示元素列表 - Unable to display list of elements using *ngFor in Angular + Spring Boot project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM