什么是JSF資源庫(kù)以及如何使用它?在JSF <h:outputStylesheet>,<h:outputScript>和<h:graphicImage>組件具有l(wèi)ibrary屬性。這是什么以及如何使用它?網(wǎng)上有很多例子,它們使用如下公共內(nèi)容/文件類型css,js以及img(或image)作為庫(kù)名,取決于使用的標(biāo)記:<h:outputStylesheet library="css" name="style.css" /><h:outputScript library="js" name="script.js" /><h:graphicImage library="img" name="logo.png" />它有用嗎?library這些示例中的值似乎只是重復(fù)標(biāo)記名稱已經(jīng)表示的內(nèi)容。對(duì)于<h:outputStylesheet>它來(lái)說(shuō),基于標(biāo)簽名稱已經(jīng)很明顯它代表了一個(gè)“CSS庫(kù)”。與以下內(nèi)容有什么不同,它們的工作方式相同?<h:outputStylesheet name="css/style.css" /><h:outputScript name="js/script.js" /><h:graphicImage name="img/logo.png" />此外,生成的HTML輸出有點(diǎn)不同。給定URL模式的上下文路徑/contextname和FacesServlet映射*.xhtml,前者生成以下HTML,其庫(kù)名稱為請(qǐng)求參數(shù):<link rel="stylesheet" type="text/css" href="/contextname/javax.faces.resource/style.css.xhtml?ln=css" /><script type="text/javascript" src="/contextname/javax.faces.resource/script.js.xhtml?ln=js"></script><img src="/contextname/javax.faces.resource/logo.png.xhtml?ln=img" alt="" />而后者在URI的路徑中生成以下帶有庫(kù)名的HTML:<link rel="stylesheet" type="text/css" href="/contextname/javax.faces.resource/css/style.css.xhtml" /><script type="text/javascript" src="/contextname/javax.faces.resource/js/script.js.xhtml"></script><img src="/contextname/javax.faces.resource/img/logo.png.xhtml" alt="" />后一種方法在事后看來(lái)也比前一種方法更有意義。該library屬性究竟有用嗎?
什么是JSF資源庫(kù)以及如何使用它?
慕森王
2019-05-29 16:15:17