Eclipse Facelets项目中无法识别Primefaces标记

jso*_*639 0 eclipse facelets primefaces jsf-2

我正在尝试制作一个简单的PrimeFaces示例,例如他们网站上的教程.我基本上和这个用户有完全相同的问题,但我没有像他那样的空jar文件.h:标签渲染正常,但p:标签在HTML中显示为p:标签.PrimeFaces 3.1.1和3.2也存在同样的问题.这是我的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_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>jsf</display-name>
  <welcome-file-list>
    <welcome-file>Login.xhtml</welcome-file>
  </welcome-file-list>
  <context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>resources.application</param-value>
 </context-param>
  <context-param>
    <description>State saving method: 'client' or 'server' (=default). See JSF    Specification 2.5.2</description>
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    <param-value>client</param-value>
  </context-param>
  <context-param>
    <description></description>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
  </context-param>
<context-param>
<description></description>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
  <context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
  <description></description>
    <param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-  class>
</listener>
<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>
Run Code Online (Sandbox Code Playgroud)

我的XHTML文件看起来像这样.

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html" 
  xmlns:p="http://primefaces.org/ui">
<h:head>
  <title><ui:insert name="title">Facelets Tutorial</ui:insert></title>
</h:head>
<body>
    <p:editor />
    <p:spinner />
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我启动我的服务器(Tomcat 6),渲染的HTML看起来像这样,h:标签渲染得很好,p:标签仍然是p:标签.

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:p="http://primefaces.org/ui"><head>
  <title>Facelets Tutorial</title></head>
<body>
    <p:editor></p:editor>
    <p:spinner></p:spinner>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我将PrimeFaces jar添加到我的构建路径中,我知道它已被识别,因为我可以在源文件中导入/使用PrimeFaces类.我甚至下载了PF源并将其添加到我的项目中以确保可以看到它,我仍然有这个问题.我的web.xml中是否需要一些额外的配置?

Bal*_*usC 6

是否构建路径,您需要确保PrimeFaces JAR文件最终/WEB-INF/lib在构建和部署的WAR文件的文件夹中结束.症状表明情况并非如此.

在Eclipse中,这只是将PrimeFaces JAR文件直接放在/WEB-INF/libWeb项目结构的文件夹中.没有别的事情要做; Eclipse会自动将其添加到构建路径和部署程序集中.在尝试安装PrimeFaces之前,不要忘记撤消在构建路径中所做的所有更改.

如果您真的坚持将JAR保留在其他位置并出于某种原因手动管理构建路径,那么您需要在项目属性的Deployment Assembly部分中手动添加它,以使其最终到达/WEB-INF/lib文件夹中战争.