为什么我的图像没有显示<p:graphicImage/>?

问题描述 投票:0回答:1

我想我尝试了在其他答案中找到的所有内容。

我正在使用 liferay 和 spring-boot 微服务。我正在通过从微服务调用端点来拍摄图像,并尝试使用 liferay 显示它。但就是不显示。

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:ui="http://java.sun.com/jsf/facelets"

 <p:panelGrid style="vertical-align: top; width:100%;" id="applicant-panel">
        <p:row>
            <p:column rowspan="5" colspan="2" styleClass="f2">

                <p:graphicImage value="#{somebean.image}" width="200"
                                id="that-image">
                </p:graphicImage>

            </p:column>

        </p:row>
 </p:panelGrid>
</ui:composition>

在一些豆子中:

   public StreamedContent getImage()  {
        FacesContext context = FacesContext.getCurrentInstance();

        if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
            return new DefaultStreamedContent();
        }
        else {        
            return new DefaultStreamedContent(new ByteArrayInputStream(SomeUtils.getThatImage(selectedPers.getid()))); //it has data in, it is not null
        }
    }

真不知道为什么不显示。感谢任何帮助。

jsf primefaces
1个回答
0
投票

我通过将 steam 属性设置为 false 解决了这个问题。我不知道为什么这有效,因为我正在返回一个流......

 <p:graphicImage value="#{somebean.image}" stream="false" width="200"
                                id="some-image">
 </p:graphicImage>
© www.soinside.com 2019 - 2024. All rights reserved.