如何在jsf中设置背景图像

时间:2014-06-02 07:52:32

标签: css jsf resources background-image

如何在jsf.i中设置背景图像想要设置(image.jpg)作为背景。图像

位于resources / images / image.jpg

<?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:f="http://java.sun.com/jsf/core"        
      xmlns:h="http://java.sun.com/jsf/html">  

    <h:head>  
        <title>JSF Example</title>                  
        <style>               
        .Bimage{background-image:url("resources/images/imag.jpg"); }        
        </style>   

    </h:head>  
    <h:body styleClass="Bimage">  

    <h:graphicImage library="images" name="download.jpg"> </h:graphicImage>    

     <h3>JSF 2 Example</h3>  
     <h:form>

        <h:inputText value="#{hello.name}"></h:inputText>  

     </h:form>  

    </h:body>  
</html>  

1 个答案:

答案 0 :(得分:3)

通过以下代码更改css .Bimage

.Bimage{
     background-image:url(#{request.contextPath}/resources/images/imag.jpg);
 }

.Bimage{
     background-image:url(/Project_Name/resources/images/imag.jpg);
 }