JSTL ForEachTag 不包含名为 setVar 的方法



情况:做一个简单的练习,从二维数组中读取国家。

目标:在 JSP 文件中循环一个字符串 [ ][ ],并打印其内容。

问题:

Type org.apache.taglibs.standard.tag.rt.core.ForEachTag contains no methods named setVar.
    <c:forEach items="${array}" var="country">
                                    ^-------^

测试:我从 Stackoverflow 和网络上看到了一些示例,它们都具有相同的语法。不知道发生了什么。

法典:

<%@ page import="service.CountryFinderSoapBindingStub"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>    
<%@ page import="java.net.URL" %>
<%@ page import="java.util.ArrayList" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
    <%
        CountryFinderSoapBindingStub c = new CountryFinderSoapBindingStub(new URL("http://localhost:7001/World_Countries/services/CountryFinder"),null);
        String[][] array = c.findAllCountries();
    %>
    The Countries are:
    <br>
    <c:forEach items="${array}" var="country">
        <p>City: <c:out value="${array[country][0]}"></c:out></p> <br> 
        <p>Country: <c:out value="${array[country][1]}"></c:out></p>
    </c:forEach>
</body>
</html>

已解决。将 jstl-1.2.jar 更改为另一个更重的 (405KB(。似乎我下载了一些较旧的东西。

相关内容

最新更新