如何在JSP中使用Facelets的ui:repeat标签? [英] How to use Facelets' ui:repeat tag in JSP?

查看:111
本文介绍了如何在JSP中使用Facelets的ui:repeat标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JSP 2.1上使用JSF 2.0.是否有可能在JSP文件中使用Facelets的<ui:repeat>标记?

I am using JSF 2.0 on JSP 2.1. Is there any possibility to use Facelets' <ui:repeat> tag in JSP files?

我已将JSP中的Facelets taglib导入为

I have imported the Facelets taglib in JSP as

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

但是它不能识别jsf-impl.jar随附的taglib ui.taglib.xml,并且渲染时间错误为

But it is not identifying the taglib ui.taglib.xml that comes with jsf-impl.jar and gives an error in render time as

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

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

但是此<ui:repeat>标记在我的Facelets文件中可以正常工作.

But this <ui:repeat> tag works fine in my Facelets files.

推荐答案

这是不可能的. Facelets是一种独特的视图技术,从技术上讲是JSP的继承者.您不能混合使用它们,也不能在JSP文件中使用Facelets标记.对于JSF2,强烈建议使用Facelets代替JSP,因为它比JSP优越得多.

That's not possible. Facelets is a distinct view technology and technically the successor of JSP. You cannot mix them nor use Facelets tags in JSP files. For JSF2 it's strongly recommended to use Facelets instead of JSP as it's far superior over JSP.

对于JSP,最好的选择是使用 JSTL <c:forEach> .它具有相似的语法,仅使用items属性而不是value.或者,如果它需要像<ui:repeat>这样的渲染时标签而不是构建时标签,则可以考虑查看 .

For JSP, your best bet is using JSTL <c:forEach> instead. It has similar syntax, only the items attribute is been used instead of value. Or if it needs to be a render-time tag like <ui:repeat> instead of a build-time tag, then consider looking at Tomahawk's <t:dataList>.

这篇关于如何在JSP中使用Facelets的ui:repeat标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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