JSTL forEach不在JSP中工作

JSTL forEach不在JSP中工作,jsp,maven,tomcat,jstl,Jsp,Maven,Tomcat,Jstl,我有一个带有一些JSTL标记的JSP,它们都可以很好地工作,但是forEach。这是我的JSP代码: header.jsp <!DOCTYPE html> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags

我有一个带有一些JSTL标记的JSP,它们都可以很好地工作,但是forEach。这是我的JSP代码:

header.jsp

    <!DOCTYPE html>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="sec"
        uri="http://www.springframework.org/security/tags"%>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
    <%@ page isELIgnored="false"%>

    <meta charset="utf-8">

    <div>
       <!-- header stuff -->
    </div>
<html>
<head></head>
<body>
    <%@include file="header.jsp"%>
    <c:if test='${pageContext["request"].userPrincipal.principal.enabled eq false}'>
          <div class='alert alert-warn fade in'>
          ....
      </div>
    </c:if>

    <table>
         <c:choose>
               <c:when test="${not empty results}">
                   <c:forEach var="item" items="${results}">
                     ...
                   </c:forEach>
               </c:when>
               <c:otherwise>
                  <tr id="noItems" class="accordion-toggle" >
                      <td>No items.</td>
                  </tr>
               </c:otherwise>
     </c:choose>
    </table>

</html>

home.jsp

    <!DOCTYPE html>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="sec"
        uri="http://www.springframework.org/security/tags"%>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
    <%@ page isELIgnored="false"%>

    <meta charset="utf-8">

    <div>
       <!-- header stuff -->
    </div>
<html>
<head></head>
<body>
    <%@include file="header.jsp"%>
    <c:if test='${pageContext["request"].userPrincipal.principal.enabled eq false}'>
          <div class='alert alert-warn fade in'>
          ....
      </div>
    </c:if>

    <table>
         <c:choose>
               <c:when test="${not empty results}">
                   <c:forEach var="item" items="${results}">
                     ...
                   </c:forEach>
               </c:when>
               <c:otherwise>
                  <tr id="noItems" class="accordion-toggle" >
                      <td>No items.</td>
                  </tr>
               </c:otherwise>
     </c:choose>
    </table>

</html>

....
...
没有物品。
我看不到任何东西,也看不到结果,也看不到“无项目”消息

我的依赖项如下:

<dependencies>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <type>jar</type>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>provided</scope>
    </dependency>

</dependencies>

javax.servlet
servlet api
2.5
罐子
假如
javax.servlet
jstl
1.2
假如
web.xml

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
              http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5" xmlns="http://java.sun.com/xml/ns/javaee">

部署在Tomcat6上不起作用,但如果我使用Maven tomcat插件将其部署在Eclipse上,效果会很好。 有人知道哪里会出错吗

编辑:

我在控制台中遇到以下错误:

[TagLibraryInfo]属性中的未知元素(延迟值)

使用Eclipse“Open Type”对话框,我提出了两个forEach实现。一个在
jasper compiler.jar
中,从hbase依赖项自动导入,另一个在
velocity.jar
中。 它们与我当前的forEach实现相冲突

将这些JAR从依赖项中排除后,问题就消失了。

使用Eclipse“Open Type”对话框,我提出了两个forEach实现。一个在
jasper compiler.jar
中,从hbase依赖项自动导入,另一个在
velocity.jar
中。 它们与我当前的forEach实现相冲突


将这些JAR从我的依赖项中排除,问题就不存在了。

Tomcat没有提供现成的JSTL,但是您已经告诉Maven情况就是这样。换言之,您以某种方式手动安装了它,但由于出现了一些症状(例如API/impl不匹配或重复;错误消息提示您实际使用的是JSTL 1.1 impl和JSTL 1.2 API),该部分很可能是错误的。如果您详细介绍如何安装JSTL,那么我们可以指出错误。与此同时,仔细阅读@BalusC I编辑了这篇文章,展示了当前的版本。我所做的唯一一件事就是将这些依赖项添加到pom.xml中。Tomcat是全新的。我也在使用SpringMVC3.2.1.RELEASE,它是否可能在任何地方包含JSTL1.1?不知道。提取Maven构建的WAR文件并检查
/WEB-INF/lib
@BalusC中的jar。我检查了它,但没有JSTL1.1 jar,只有JSTL1.2.jarJSTL 1.1 impl具有(相当混乱的)文件名
standard.jar
。您是否也专门考虑过这个问题?Tomcat没有提供现成的JSTL,但您已经告诉Maven情况就是这样。换言之,您以某种方式手动安装了它,但由于出现了一些症状(例如API/impl不匹配或重复;错误消息提示您实际使用的是JSTL 1.1 impl和JSTL 1.2 API),该部分很可能是错误的。如果您详细介绍如何安装JSTL,那么我们可以指出错误。与此同时,仔细阅读@BalusC I编辑了这篇文章,展示了当前的版本。我所做的唯一一件事就是将这些依赖项添加到pom.xml中。Tomcat是全新的。我也在使用SpringMVC3.2.1.RELEASE,它是否可能在任何地方包含JSTL1.1?不知道。提取Maven构建的WAR文件并检查
/WEB-INF/lib
@BalusC中的jar。我检查了它,但没有JSTL1.1 jar,只有JSTL1.2.jarJSTL 1.1 impl具有(相当混乱的)文件名
standard.jar
。你也专门找过这个吗?