Hudson Bui
Hudson Bui

Reputation: 1

Display image problem in JSF with graphicImage

I am new to JSF and trying to display an image using graphicImage, but I hit a problem that there is no image displayed. I check all the hint that chatGPT shows me but it still doesn't work. The code, the folder structure, the image validity, ... Here the code

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">

<h:head>
    <title>Survey Website</title>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
</h:head>

<h:body>
    <h:form>
        <h:panelGrid>
            <h:graphicImage alt="There is error" library="image" name="/form.png" />
            <h2>Khảo sát</h2>
        </h:panelGrid>
    </h:form>
</h:body>
</html>

enter image description here

I try these alternative code but it's also doesn't work.

<h:graphicImage alt="There is error" library="image" name="/form.png" />  
<h:graphicImage alt="There is error" url="/resources/image/form.png" />   
<h:graphicImage alt="There is error" value="/resources/image/form.png" />

I also tried to set the width and height of this image but the size that I see in the web when I inspect it is still 0x0enter image description here enter image description here I also check the console and I see those errors, I don't know if it relevant to my problem

Upvotes: 0

Views: 69

Answers (0)

Related Questions