【发布时间】:2011-05-02 10:33:43
【问题描述】:
我一直在尝试让 JSTL 在 Eclipse 下工作(最终在 GAE/J 下)工作的时间比我想承认的要长。我已经下载了 Eclipse、Google App Engine Extension for Eclipse 和 JSTL(http://download.java.net/maven/1/jstl/jars/ - jstl-1.2.jar 在 WEB-INF\lib 目录中)。
我的代码和输出如下:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<HTML><HEAD><TITLE>Test Page</TITLE></HEAD><BODY>
Test Page
<c:set var="myvar" value="3"/>
</BODY></HTML>
我得到的错误是:
The tag handler class for "c:set" (org.apache.taglibs.standard.tag.rt.core.SetTag) was not found on the Java Build Path
test.jsp
[my app's path and name]
line 8
JSP Problem
从本页的最后一篇文章来看,我认为我不需要standard.jar (http://forums.sun.com/thread.jspa?threadID=701267),无论如何,我在Oracle download.java.com 网站上找不到一个和jstl jar 一起的.
编辑 4:现在可以使用 - 步骤:
1) 使用 Apache 版本
2)实际上在构建路径中包含jar文件(右键单击eclipse项目并点击属性-> Java构建路径->库->添加类文件夹...;war/WEB-INF/lib显然不在默认构建路径)
3) 将文件 c.tld 添加到 war/WEB-INF/tld
让你的 web.xml 看起来像:
<\?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>JSTLExample</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
<taglib-location>/WEB-INF/tld/c.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>
测试jsp文件内容:
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!-- Taglib -->
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Test Apache ServiceMix with JSTL</title>
</head>
<body>
This is a testpage.
<%= "hello" %>
<c:forEach var="i" begin="1" end="10" step="1">
<c:out value="${i}" />
<br />
</c:forEach>
</body>
</html>
【问题讨论】:
-
这很奇怪:我对 jstl.jar 也有同样的问题,如果我是从你说它工作的地方下载的。
标签: java eclipse google-app-engine jsp servlets