我正在使用 primefaces 3.3.1 和 Myfaces 2.1.1 配置一个项目。我运行了一个简单的展示示例,但此示例仅显示文本,没有 CSS 内容。我在 xhtml 中看到使用手动导入 css 的任何示例,但我认为这不是一个好方法。
pom.xml:
<dependencies>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<version>2.1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<version>2.1.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency
<!-- Primefaces dependency -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>3.3.1</version>
</dependency>
<!-- Themes PrimeFaces -->
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>bluesky</artifactId>
<version>1.0.6</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>prime-repo</id>
<name>PrimeFaces Maven Repository</name>
<url>http://repository.primefaces.org</url>
<layout>default</layout>
</repository>
</repositories>
网页内容/WEB-INF/Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>meu-projeto</display-name>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>br.com.meuprojeto.servlet.HelloServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>*.teste</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/HelloServlet</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout> <!-- 30 minutes -->
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>bluesky</param-value>
</context-param>
</web-app>
我的页面:
<html xmlns="http://www.w3c.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">
<h:head>
</h:head>
<h:body>
<h:form id="form">
<p:panel header="Enter your passwords">
<h:panelGrid columns="2">
<h:outputText value="Basic: " />
<p:password id="nonFeedback" value="" />
</h:panelGrid>
</p:panel>
<p:spacer height="10" />
<p:panel header="Match Mode">
<p:messages id="messages" showDetail="true" autoUpdate="true" />
<p:commandButton id="saveButton" update="matchGrid" value="Save" />
</p:panel>
</h:form>
</h:body>
</html>
然后项目 > 属性 > 部署程序集 > 添加 > Java 构建路径条目并添加所有 jar。所以,在图书馆项目中有所有的罐子。