如何将 css 文件添加到 Maven 项目 + primefaces
how to add css file to maven project + primefaces
我的 css 文件发送工作。
歌剧给我看:
http://localhost:8080/formularz-web/faces/javax.faces.resource/css/mycss.css Failed to load resource: the server responded with a status of 404 (Not Found)
netbens 给我看:
Warning: JSF1064: Unable to find or serve resource, css/mycss.css.
这意味着我的项目没有看到 css 文件。
在 index.xhtml 我有:
<html xmlns="http://www.w3c.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Kwestionarisz osobowy - rejestracja PAW</title>
</h:head>
<h:body>
<f:facet name="last">
<h:outputStylesheet name="css/mycss.css" />
</f:facet>
<h:form styleClass="mycss">
我尝试将 h:outputStylesheet 放入 h:head。
我试过不使用 f:facet。
我尝试添加库="css"。
我尝试了另一个文件路径:
h:outputStylesheet name="mycss.css"(删除css文件夹,将css文件直接放到webapp
h:outputStylesheet 姓名="src/main/webapp/css/mycss.css"
h:outputStylesheet name="#{request.contextPath}/css/mycss.css"
我错了什么
JSF 在 /webapp/resources
中搜索资源(js、css 等)。
您必须将 css 放在这样的目录中 /webapp/resources/css/mycss.css
。在您的 xhtml/jsf 文件中:
<h:body>
..
<h:outputStylesheet name="mycss.css" library="css" />
我的 css 文件发送工作。
歌剧给我看:
http://localhost:8080/formularz-web/faces/javax.faces.resource/css/mycss.css Failed to load resource: the server responded with a status of 404 (Not Found)
netbens 给我看:
Warning: JSF1064: Unable to find or serve resource, css/mycss.css.
这意味着我的项目没有看到 css 文件。
在 index.xhtml 我有:
<html xmlns="http://www.w3c.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Kwestionarisz osobowy - rejestracja PAW</title>
</h:head>
<h:body>
<f:facet name="last">
<h:outputStylesheet name="css/mycss.css" />
</f:facet>
<h:form styleClass="mycss">
我尝试将 h:outputStylesheet 放入 h:head。
我试过不使用 f:facet。
我尝试添加库="css"。
我尝试了另一个文件路径:
h:outputStylesheet name="mycss.css"(删除css文件夹,将css文件直接放到webapp
h:outputStylesheet 姓名="src/main/webapp/css/mycss.css"
h:outputStylesheet name="#{request.contextPath}/css/mycss.css"
我错了什么
JSF 在 /webapp/resources
中搜索资源(js、css 等)。
您必须将 css 放在这样的目录中 /webapp/resources/css/mycss.css
。在您的 xhtml/jsf 文件中:
<h:body>
..
<h:outputStylesheet name="mycss.css" library="css" />