2017-06-21 29 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)。看來我下載了一些舊的東西。

相關問題