如何将外部CSS资源与JSF h:outputStylesheet链接?

Syd*_*ney 8 jsf external-url outputstylesheet

我想知道我是否可以使用<h:outputStylesheet/>从外部资源链接CSS.我想链接雅虎网格.使用以下代码,我得到了一个RES_NOT_FOUND:

<?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"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:tcmt="http://java.sun.com/jsf/composite/tcmt/component">

    <h:head>
    </h:head>
    <h:body>
        <h:outputStylesheet library="css" name="http://yui.yahooapis.com/3.3.0/build/cssgrids/grids-min.css" target="head" />
     </h:body>
</html>
Run Code Online (Sandbox Code Playgroud)

Val*_*lva 16

您可以继续使用纯HTML:

<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/3.3.0/build/cssgrids/grids-min.css" />
Run Code Online (Sandbox Code Playgroud)

当您使用<h:graphicImage/><h:outputStylesheet/>或时<h:outputScript/>,该文件需要/resources位于Web应用程序本身的文件夹中.另请参见如何在Facelets模板中引用CSS/JS /图像资源?但是,如果Web应用程序未提供该文件,那么您应该使用纯HTML <img/><link/><script></script>为此.

不是纯HTML的<link/>,你也可以下载这个.css,把在/resourcesWeb应用程序的文件夹,这样就可以使用<h:outputStylesheet/>.