我想知道在自定义portlet的jsp中显示DLFileEntry图像的所有可能方式。
更具体地说,我目前使用以下方式,但是DLFileEntry对象存在一些问题,这些对象的'largeimageid'值为零

DLFileEntry image = DLFileEntryLocalServiceUtil.getFileEntry(long_id);
String imageUrl = themeDisplay.getPathImage() + "/image_gallery?img_id=" + image.getLargeImageId() +  "&t=" + WebServerServletTokenUtil.getToken(image.getLargeImageId());

在不使用大图片ID的情况下获取图片网址的替代方法有哪些?

最佳答案

以下是与Liferay 文档和Media portlet所使用的模式类似的模式:

DLFileEntry image = DLFileEntryLocalServiceUtil.getFileEntry(long_id);
String imageUrl = "";
if (image != null) {
    imageUrl =
        PortalUtil.getPortalURL(request) + "/documents/" + image.getGroupId() + "/" +
            image.getFolderId() + "/" + image.getTitle() + "/" + image.getUuid() + "?t=" +
            System.currentTimeMillis();
}
PortalUtil.getPortalURL(request)将根据httpServletRequest返回门户的基本URL,System.currentTimeMillis()将为您提供当前时间(毫秒),其余参数均可通过DLFileEntry对象获得。

08-25 22:27