我想知道我是否可以使用< 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>
解决方法
您可以继续使用纯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>为了这.
而不是简单的HTML< link />您也可以下载.css并将其放入Web应用程序的/ resources文件夹中,以便您可以使用< h:outputStylesheet />.