h:graphicImage在JSF中不显示图像

h:graphicImage在JSF中不显示图像,jsf,graphicimage,Jsf,Graphicimage,我的课堂上有这个,我正试图在我的网页上访问它 public String carImageURL = "/resources/images/sample_car.jpg"; 这是我在网页中使用的代码,它不起作用 <h:graphicImage value="#{carClass.carImageURL}"></h:graphicImage > 当我运行页面时,页面中没有汽车的图片。将carImageURL属性更改为private scope,并为其编写一个getter

我的课堂上有这个,我正试图在我的网页上访问它

public String carImageURL = "/resources/images/sample_car.jpg";
这是我在网页中使用的代码,它不起作用

<h:graphicImage value="#{carClass.carImageURL}"></h:graphicImage >

当我运行页面时,页面中没有汽车的图片。

将carImageURL属性更改为private scope,并为其编写一个getter方法。在图像路径的开头也写一条斜线:

private String carImageURL = "/resources/images/sample_car.jpg";

public String getCarImageURL() {
    return carImageURL;
}

尝试不使用/resourcesIt不起作用。图像仍然不存在。您将图像放置在何处?在webapp/resources/images foldertry中,没有第一个/>公共字符串carImageURL=resources/images/sample_car.jpg;