问题描述
我有一个JSP,
<%@taglib uri="http://java.sun.com/jsf/facelets" prefix="ui" %>
但是错误
我有库facelets-lib.jar
和jsf-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 taglib.这是永远行不通的.两者都是独特的视图技术. 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
,并将所有JSP taglib声明替换为XML名称空间声明,并删除所有<jsp:xxx>
标记和所有<% %>
脚本.
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开发人员文档(适用于Facelets 1.x)
- Java EE 6教程-Facelets (适用于Facelets 2.x)
- 包含Eclipse和Glassfish的JSF 2.0教程(从零开始)
- 从JSF 1.2迁移到JSF 2.0
- 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的标签库描述符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!