You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用<p:graphicImage/>组件无法显示图片的问题求助

<p:graphicImage/>组件无法显示图片的问题求助

我已经试过其他答案里能找到的所有方法了,但还是解决不了问题。我现在在用Liferay搭配Spring Boot微服务,通过调用微服务接口获取图片,想在Liferay里展示,但图片就是显示不出来。

我的JSF视图代码如下:

<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>

对应的somebean中的getImage方法代码:

public StreamedContent getImage()  {
    FacesContext context = FacesContext.getCurrentInstance();
    if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
        return new DefaultStreamedContent();
    } else {
        // 确认过这里返回的字节流是有数据的,不是null
        return new DefaultStreamedContent(new ByteArrayInputStream(SomeUtils.getThatImage(selectedPers.getid())));
    }
}

我实在搞不懂为啥图片就是显示不出来,有没有大佬能帮忙分析下问题所在?

备注:内容来源于stack exchange,提问作者Octavia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.21 11:24:30