我目前正在学习使用Primefaces开发JSF 2应用程序 我使用maven导入了JSF和Primefaces依赖项:
<!-- Implementação do Java Server Faces 2 (MOJARRA) -->
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.faces</artifactId>
<version>2.3.0</version>
<scope>compile</scope>
</dependency>
<!-- Implementação do PrimeFaces 6 -->
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>6.0</version>
</dependency>
</dependencies>
但我不能在我的.xhtml文件中使用带有xmlns =“http://primefaces.org/ui”的primefaces:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head></h:head>
<body>
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="Nome"/>
<h:inputText/>
</h:panelGrid>
</h:form>
</body>
</html>
当我使用Tomcat 7.0服务器运行应用程序时,我无法使用localhost访问它:8080 / projectname / pagename.xhtml
我该如何解决这个问题?
这是我的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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<welcome-file-list>
<welcome-file>algo.html</welcome-file>
</welcome-file-list>
<display-name>opn</display-name>
<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>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>