2017-06-21 28 views
0

情况: 做一个简单的练习,从二维数组读取国家。JSTL ForEachTag不包含名为setVar的方法

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

问题:

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

测试: 我看到#1和周围的净几个例子,并且都具有相同的语法。不知道发生了什么事。

代码:

<%@ 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> 

回答

0

解决。将jstl-1.2.jar更改为更重(405KB)。看来我下载了一些旧的东西。

相关问题