java JSF 2 中 JSTL forEach 的问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4086546/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Problems with JSTL forEach in JSF 2
提问by Marcel Menz
Hi I got the following code:
嗨,我得到以下代码:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
>
<h:body>
<c:forEach items="#{backingBean.personList}" var="person">
<h:outputText value="#{person.name}" />
</c:forEach>
</h:body>
</html>
This fails with:
这失败了:
java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.LoopTagStatus
I use jstl-impl-1.2.jar. Does anyone could help me on this one? Thanks
我使用 jstl-impl-1.2.jar。有没有人可以帮我解决这个问题?谢谢
Marcel
马塞尔
采纳答案by duffymo
What about standard.jar?
那么standard.jar 呢?
Do you have both JARs in WEB-INF/lib?
你在 WEB-INF/lib 中有两个 JAR 文件吗?
回答by Sean Patrick Floyd
I think you are missing a JSTL-api jar.
我认为您缺少一个 JSTL-api jar。
Classname search on sonatype's nexusreturned this maven dependency:
对sonatype 的关系的类名搜索返回了这个 Maven 依赖项:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.1.2</version>
</dependency>
You can download it from this pageif you don't use maven.
如果你不使用 maven,你可以从这个页面下载它。
You can also use Findjar.comto find occurrences of the class.
您还可以使用Findjar.com查找该类的出现次数。
回答by Vincent Ramdhanie
If memory serves me right the JSTL core uses EL which has syntax like this ${}
rather than #{}
.
如果没记错的话,JSTL 核心使用 EL,它的语法是这样的,${}
而不是#{}
.