找不到 http://java.sun.com/jsf/facelets 的标签库描述符 [英] Can not find the tag library descriptor for http://java.sun.com/jsf/facelets

查看:35
本文介绍了找不到 http://java.sun.com/jsf/facelets 的标签库描述符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 JSP

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

但是它错误

绝对uri:http://java.sun.com/jsf/facelets 不能在 web.xml 或使用此应用程序部署的 jar 文件中解析

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

我有库 facelets-lib.jarjsf-facelets-1.1.10.jar,我想它们是 Facelets,但它们不包含 JSP taglib 描述符.

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.

哪个文件是正确的?

推荐答案

Facelets 旨在完全替换 JSP.但是您试图将其声明为 JSP 标记库.这永远行不通.两者都是不同的视图技术.Facelets 是一种基于 XML 的视图技术,旨在成为 JSP 的继承者.在 2009 年 12 月发布的 Java EE 6 中,它已经取代 JSP 作为 JSF 的标准视图技术,此后 JSP 已被弃用.

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.

您需要将文件扩展名从 .jsp 重命名为 .xhtml 并用 XML 命名空间声明替换所有 JSP taglib 声明并删除所有 ; 标签和所有 <% %> 脚本.

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.

所以,例如下面的基本 JSP 模板 page.jsp

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>

必须重写为 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>

最后,提到的 JAR 文件是 Facelets 1.x JAR,而 Facelets 2.x 自 2009 年以来已经作为 一个 JSF 2.x 实现.如果可以,我强烈建议您跳过 Facelets 1.x,继续使用 Facelets 2.x.

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.

  • 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

这篇关于找不到 http://java.sun.com/jsf/facelets 的标签库描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆