我遇到了这个问题,我不知道为什么会这样,我尝试了很多东西,但是......没有成功,谢谢你的帮助。
这就是问题:
GRAVE: Servlet.service() para servlet [Faces Servlet] lanzó excepción java.io.IOException: javax.el.PropertyNotFoundException: /catalogoAdmin.xhtml @16,40 value="#{catalogoBean.image}": Propiedad [image] no hallada en el tipo [beans.CatalogoBean] at org.primefaces.component.graphicimage.GraphicImageRenderer.encodeEnd(GraphicImageRenderer.java:43) at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:919) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863) at javax.faces.render.Renderer.encodeChildren(Renderer.java:176) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:889) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1856) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859) at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:456) at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:133) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219) at javax.faces.webapp.FacesServlet.service(FacesServlet.java:647)
这是我的代码:
方法Bean
public StreamedContent getImage() throws IOException {
FacesContext context = FacesContext.getCurrentInstance();
if (context.getCurrentPhaseId() == PhaseId.RENDER_RESPONSE) {
return new DefaultStreamedContent();
} else {
String filename = context.getExternalContext().getRequestParameterMap().get("nombre");
return new DefaultStreamedContent(new FileInputStream(new File("C:\\images/", filename)));
}
}
XHTML
<h:form id="formImg">
<p:graphicImage value="#{catalogoBean.image}"
style="height:150px; width:150px;">
<f:param name="nombre" value="ram.png" />
</p:graphicImage>
</h:form>