[英]h:graphicImage does not display image in JSF
I have this in my class and I am trying to access it on my web page. 我班上有这个,我想在我的网页上访问它。
public String carImageURL = "/resources/images/sample_car.jpg";
This is the code I use in my web page that does not work. 这是我在网页中无法使用的代码。
<h:graphicImage value="#{carClass.carImageURL}"></h:graphicImage >
When I run the page there is no picture of the car in it. 当我运行该页面时,其中没有汽车的图片。
Change the carImageURL attribute to private scope and write a getter method for it. 将carImageURL属性更改为私有范围,并为其编写getter方法。 Also write a slash at the beginning of the image path: 还要在图像路径的开头写一个斜杠:
private String carImageURL = "/resources/images/sample_car.jpg";
public String getCarImageURL() {
return carImageURL;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.