[英]JSF doesn't read external css file
i have an external CSS file in the resources folder under WebContent folder, and i included it at the page header as follows: 我在WebContent文件夹下的resources文件夹中有一个外部CSS文件,并将其包含在页面标题中,如下所示:
<h:head>
<h:outputStylesheet name="css/style.css" library="css" />
</h:head>
i tried a simple selector to test the if the file is working like body {background-color:#b0c4de;}
but unfortunately the file isn't linked 我尝试了一个简单的选择器来测试文件是否像body {background-color:#b0c4de;}
但不幸的是该文件未链接
for more clarity i included here a screenshot for the exact location of the resources folder 为了更清晰起见,我在此处包括了资源文件夹的确切位置的屏幕截图
First of all, this is not an external CSS file at all. 首先,这根本不是外部CSS文件。 It's internal to your web application. 它在您的Web应用程序内部。 A real external CSS file would be served from a different domain and is not importable via <h:outputStylesheet>
, but only via <link>
. 真正的外部CSS文件将从其他域提供,并且不能通过<h:outputStylesheet>
导入,而只能通过<link>
导入。
Your concrete problem is caused because you unnecessarily repeated the CSS file folder into the library
attribute. 造成您的具体问题的原因是,您不必要地将CSS文件文件夹重复到library
属性中。 Just get rid of it. 摆脱它。
<h:outputStylesheet name="css/style.css" />
The library
attribute must represent the common module/theme/library name, such as "primefaces", but you don't have any here. library
属性必须代表通用的模块/主题/库名称,例如“ primefaces”,但此处没有任何属性。 Using a library name of "css" makes no utter sense as "css" just represents the file/content type. 使用库名“ css”没有任何意义,因为“ css”仅表示文件/内容类型。
Try h:outputStylesheet name="style.css" library="css" /> 尝试h:outputStylesheet name =“ style.css” library =“ css” />
here is a ref: http://www.mkyong.com/jsf2/how-to-include-cascading-style-sheets-css-in-jsf/ 这是一个参考: http : //www.mkyong.com/jsf2/how-to-include-cascading-style-sheets-css-in-jsf/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.