我想知道我是否可以使用<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>
答案 0 :(得分:14)
您可以继续使用纯HTML:
<link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/3.3.0/build/cssgrids/grids-min.css" />
当您使用<h:graphicImage/>
或<h:outputStylesheet/>
或<h:outputScript/>
时,该文件必须位于Web应用程序本身的/resources
文件夹中。另请参阅How to reference CSS / JS / image resource in Facelets template?但是,如果Web应用程序未提供该文件,则应使用纯HTML <img/>
或<link/>
或<script></script>
。
您也可以下载此<link/>
而不是纯HTML .css
,并将其放入网络应用程序的/resources
文件夹中,以便您可以使用<h:outputStylesheet/>
。