Can not find the tag library descriptor for http://java.sun.com/jsf/facelets

孤人 提交于 2019-11-26 13:53:27

问题


I've a JSP with

<%@taglib uri="http://java.sun.com/jsf/facelets" prefix="ui" %>

However it errors with

The absolute uri: http://java.sun.com/jsf/facelets cannot be resolved in either web.xml or the jar files deployed with this application

I have libraries facelets-lib.jar and jsf-facelets-1.1.10.jar, which I suppose is Facelets, but they do not contain JSP taglib descriptors.

What file is correct?


回答1:


Facelets is intented to replace JSP altogether. But yet you're attempting to declare it as a JSP taglib. This is never going to work. Both are distinct view technologies. Facelets is a XML based view technology which is designed to be a successor of JSP. In Java EE 6 which was released december 2009 it has already replaced JSP as standard view technology for JSF and JSP has since then been deprecated.

You need to rename file extension from .jsp to .xhtml and replace all JSP taglib declarations by XML namespace declarations and remove all <jsp:xxx> tags and all <% %> scriptlets.

So, for example the following basic JSP template page.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<!DOCTYPE html>
<f:view>
    <html lang="en">
        <head>
            <title>JSP page</title>
        </head>
        <body>
            <h:outputText value="JSF components here." />
        </body>
    </html>
</f:view>

has to be rewritten as page.xhtml

<!DOCTYPE html>
<html lang="en"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets">
    <head>
        <title>Facelet page</title>
    </head>
    <body>
        <h:outputText value="JSF components here." />
    </body>  
</html>

Finally, the mentioned JAR files are Facelets 1.x JARs while Facelets 2.x is already been out since 2009 as part of a JSF 2.x implementation. If you can, I'd strongly recommend to just skip Facelets 1.x and continue with Facelets 2.x.

See also:

  • Facelets Developer Documentation (for Facelets 1.x)
  • Java EE 6 tutorial - Facelets (for Facelets 2.x)
  • JSF 2.0 tutorial with Eclipse and Glassfish (to start from zero)
  • Migrating from JSF 1.2 to JSF 2.0



回答2:


If you are using JSF 2, you will need the jsf-api.jar and the jsf-impl.jar.
If you are using JSF 1, look at here



来源:https://stackoverflow.com/questions/6322127/can-not-find-the-tag-library-descriptor-for-http-java-sun-com-jsf-facelets

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!