Eclipse需要什么JAR文件才能使用JSTL,因此最终可以在GAE / J上运行? [英] What JAR files are needed for Eclipse to use JSTL so it ultimately works on GAE/J?
问题描述
我一直在尝试比我想承认JSTL在Eclipse(最终在GAE / J下)工作的时间更长。我已经下载了Eclipse,Eclipse的Google App Engine扩展版和JSTL( http: /download.java.net/maven/1/jstl/jars/ - jstl-1.2.jar在WEB-INF \lib目录中)
我的代码与输出一起:
<%@ taglib uri =http://java.sun .com / jsp / jstl / coreprefix =c%>
< HTML>< HEAD>< TITLE>测试页< / TITLE>< / HEAD>< BODY>
测试页
< c:set var =myvarvalue =3/>
< / BODY>< / HTML>
我遇到的错误是:
在Java Build Path
测试中找不到c:set(org.apache.taglibs.standard.tag.rt.core.SetTag)的标记处理程序类。 jsp
[我的应用程序的路径和名称]
行8
JSP问题
从本页的最后一篇文章我不认为我需要一个standard.jar( http://forums.sun.com/thread.jspa?threadID=701267 ),在任何情况下,我都无法在Oracle download.java.com网站上找到一个jstl jar。 p>
编辑4:现在工作 - 步骤:
1)使用Apache版本
2)实际上将jar文件包含在构建路径(右键单击eclipse项目并点击属性 - > Java构建路径 - >库 - >添加类文件夹...; war / WEB-INF / lib显然不在默认情况下在构建路径上)
3)将文件c.tld添加到war / WEB-INF / tld
使您的web.xml看起来像:
< \?xml version =1.0encoding =UTF-8 >?;
< web-app version =2.4xmlns =http://java.sun.com/xml/ns/j2eexmlns:xsi =http://www.w3.org/2001/ XMLSchema-instancexsi: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.0encoding =UTF-8?>
<%@ page language =javacontentType =text / html; charset = UTF-8pageEncoding =UTF-8%>
<! - Taglib - >
<%@ taglib uri =http://java.sun.com/jstl/coreprefix =c%>
<!DOCTYPE html PUBLIC - // W3C // DTD XHTML 1.0 Transitional // ENhttp://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional。 DTD>
< html xmlns =http://www.w3.org/1999/xhtml>
< head>
< meta http-equiv =Content-Typecontent =text / html; charset = UTF-8/>
< title>使用JSTL< / title>测试Apache ServiceMix
< / head>
< body>
这是一个测试页。
<%=hello%>
< c:forEach var =ibegin =1end =10step =1>
< c:out value =$ {i}/>
< br />
< / c:forEach>
< / body>
< / html>
确保您的网页。 xml
根声明符合至少 Servlet 2.4。
< web -app
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
版本= 2.4 >
<! - 在这里配置。 - >
< / web-app>
或者如果您的servlet容器支持它,则更喜欢2.5:
< web-app
xmlns =http://java.sun.com/xml/ns/javaee
xmlns:xsi = http://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/ xml / ns / javaee / web-app_2_5.xsd
version =2.5>
<! - 在这里配置。 - >
< / web-app>
如果支持最新版本3.0,
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ http http http http http http http http http http http http http http http http http http http http http http ://www.w3.org/2001/XMLSchema-instance
xsi:schemaLocation =http://java.sun.com/xml/ns/javaee http://java.sun.com/xml /ns/javaee/web-app_3_0.xsd
version =3.0>
<! - 在这里配置。 - >
< / web-app>
否则,一切都会回退到最少支持的模式,而taglib可能会这样破坏。
还要确保您没有松动的 tld
在类路径中漫游的文件( / WEB- INF / lib
文件夹等),它们将与JAR文件中的那些文件冲突。哦,还要确保你没有在 web.xml
中手动定义tld,保持清洁。
I've been trying for longer than I'd like to admit to get JSTL working under Eclipse (and ultimately under GAE/J). I've downloaded Eclipse, the Google App Engine Extension for Eclipse, and JSTL (http://download.java.net/maven/1/jstl/jars/ - jstl-1.2.jar is in the WEB-INF\lib directory).
My code is below along with the output:
<%@ 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 error I get is:
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
From the last post on this page I don't think I need a standard.jar (http://forums.sun.com/thread.jspa?threadID=701267) and in any case I couldn't find one on the Oracle download.java.com site along with the jstl jar.
EDIT 4: Works now - Steps:
1) Use the Apache version
2) Actually include the jar file in the build path (right click the eclipse project and hit Properties -> Java Build Path -> Libraries -> Add Class Folder...; the war/WEB-INF/lib is apparently not on the build path by default)
3) Add the file c.tld to war/WEB-INF/tld
Make your web.xml look like:
<\?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>
The test jsp file contents:
<?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>
Ensure that your web.xml
root declaration complies at least Servlet 2.4.
<web-app
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"
version="2.4">
<!-- Config here. -->
</web-app>
Or if your servletcontainer supports it, prefer 2.5:
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<!-- Config here. -->
</web-app>
O if it supports the latest version3.0
<web-app
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<!-- Config here. -->
</web-app>
Otherwise everything will fall back to least supported modus and taglibs may break like that.
Also ensure that you don't have loose tld
files wandering around in the classpath (the /WEB-INF/lib
folder, among others), they will collide with the ones in JAR files. Oh, also ensure that you didn't manually define the tlds in web.xml
, keep it clean.
这篇关于Eclipse需要什么JAR文件才能使用JSTL,因此最终可以在GAE / J上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!