5

我正在开发一个应用程序(在 Eclipse 上),在 Tomcat 上带有一些 jsp 页面。

我已经下载了 JSTL jars

(http://jstl.java.net/download.html) 

并将它们添加到 web-inf/lib 和我的构建路径中。

但是,当我访问该页面时,我总是得到:

SEVERE: Servlet.service() for servlet [jsp] in context with path [/AccessControl2] threw exception [/ADAccess.jsp (line: 16, column: 1) No tag "foreach" defined in tag library imported with prefix "c"] with root cause

org.apache.jasper.JasperException: /ADAccess.jsp (line: 16, column: 1) No tag "foreach" defined in tag library imported with prefix "c"

这是我的 web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">

至于我的 JSP,我是这样做的:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"   "http://www.w3.org/TR/html4/loose.dtd">

<HTML>
<BODY>
<script type="text/javascript" src="saveOptions.js"></script>
<FORM METHOD=POST ACTION="SaveADAccess.jsp">

<jsp:useBean id="obj" class="nbsi.config.access.ADGroupListBean" scope="page"/>

<select name="withoutAccess" size="5">

<c:foreach var="item" items="${obj.withoutAccess}">
    <option>${item}</option>
    </c:foreach>
</select>

<select name="withAccess" size="5">

</select>
<P>
        <INPUT TYPE=SUBMIT> 
    <input type="button" onClick="removeOptions(withoutAccess,withAccess)"value="Give Access" />
        <input type="button" onClick="removeOptions(withAccess,withoutAccess)"value="Remove Access" />
</FORM>
</BODY>
</HTML>

我已经搜索过这个问题,但解决方案对我不起作用。

4

2 回答 2

18

我认为标记名区分大小写。改用. <c:forEach_<c:foreach

于 2012-06-26T17:46:43.540 回答
-1

请参阅以下链接, https://springbootmvc.blogspot.com/2020/06/jstl-core-tag.html

确保要添加的标头正确,<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

于 2020-06-27T10:08:15.497 回答