[英]How to replace broken images with a blank image in JSF?
I'm using the h:graphicImage
tag in JSF. 我在JSF中使用
h:graphicImage
标记。 Is there a way to show a blank image (ie blank.jpg) if there is a broken or not found image? 如果有损坏的或找不到的图像,是否可以显示空白图像(即blank.jpg)?
There are two ways: 有两种方法:
ImageServlet
which takes an image url, loads it and sees if it exists. ImageServlet
接收图像URL,将其加载并查看其是否存在。 If it exists, it is streamed to to client. new File(fullPathToImage).exists()
, or, if the image is not on your server, using URL.openConnection()
. new File(fullPathToImage).exists()
,或者如果图像不在服务器上,则可以使用URL.openConnection()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.