How to use Facelets' ui:repeat tag in JSP?

孤者浪人 提交于 2019-12-11 03:33:29

问题


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

I have imported the Facelets taglib in JSP as

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

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: The absolute uri: http://java.sun.com/jsf/facelets cannot be resolved in either web.xml or the jar files deployed with this application

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


回答1:


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.

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>.



来源:https://stackoverflow.com/questions/7006104/how-to-use-facelets-uirepeat-tag-in-jsp

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