JSTL 在 GoogleAppEngine 的开发服务器上中断,但可以在远程服务器上运行
正如标题所示,我的 JSTL 标签不能在我的开发服务器上工作,但可以在 Google 的实际服务器上工作。
我将代码简化为简单的代码,以确保代码没有任何问题,所以这就是我所得到的。
JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Page Title</title>
</head>
<body>
<c:choose>
<c:when test="${2+2==4}">sum works</c:when>
<c:otherwise>sum doesn't work</c:otherwise>
</c:choose>
</body>
我的配置如下(我认为这是正确的并且可以在Google的服务器上运行): 我正在使用
- Eclipse IDE
- Servlet 2.5
- 没有将 jstl jar 添加到 WEB-INF\lib
- 没有在任何地方添加 tld
- 没有 taglib 引用
web.xml 上
但是,我也尝试了以下多种组合,但没有一个起作用:
- jstl- 1.2.jar 添加到构建路径
- c.tld 添加到 WEB-INF
- taglib 引用添加到 web.xml
错误如下:
HTTP ERROR 500
Problem accessing /index.html. Reason:
javax/servlet/jsp/tagext/TagSupport
Caused by:
java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagSupport
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:927)
at java.lang.ClassLoader.loadClass(ClassLoader.java:298)
at com.google.appengine.tools.development.DevAppServerClassLoader.loadClass(DevAppServerClassLoader.java:87)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at com.google.appengine.tools.development.DevAppServerClassLoader.loadClass(DevAppServerClassLoader.java:87)
...
但奇怪的是,
适用于开发服务器和远程服务器。其他核心标签不起作用。如果我尝试添加 fmt 标签,它们就不起作用。
有什么想法吗?
As the title says, my JSTL tags don't work on my development server, but do work on Google's actual server.
I simplified the code to the bare bone to make sure there wasn't anything wrong with the code, so here's what I've got.
JSP
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" isELIgnored="false"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Page Title</title>
</head>
<body>
<c:choose>
<c:when test="${2+2==4}">sum works</c:when>
<c:otherwise>sum doesn't work</c:otherwise>
</c:choose>
</body>
My configuration is as follows (which I think is correct and which works on Google's server):
I'm using
- Eclipse IDE
- Servlet 2.5
- No jstl jar added to WEB-INF\lib
- No tld added anywhere
- No taglib reference
on web.xml
However, I have also tried a number of combinations of the following and none of them worked:
- jstl-1.2.jar added to the build path
- c.tld added to WEB-INF
- taglib reference added to web.xml
Error is below:
HTTP ERROR 500
Problem accessing /index.html. Reason:
javax/servlet/jsp/tagext/TagSupport
Caused by:
java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/TagSupport
at java.lang.ClassLoader.findBootstrapClass(Native Method)
at java.lang.ClassLoader.findBootstrapClassOrNull(ClassLoader.java:927)
at java.lang.ClassLoader.loadClass(ClassLoader.java:298)
at com.google.appengine.tools.development.DevAppServerClassLoader.loadClass(DevAppServerClassLoader.java:87)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at com.google.appengine.tools.development.DevAppServerClassLoader.loadClass(DevAppServerClassLoader.java:87)
...
Strangely, though, <c:out value="${blah}"/>
works both on the development and remote servers. other core tags don't work. If I try to add fmt tags, they don't work as well.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将 JSTL JAR 放入
/WEB-INF/lib
中,或者至少放入您在本地开发中使用的 servlet 容器的/lib
文件夹中。您不应该提取 JAR 并用松散的 TLD 文件扰乱 Web 应用程序,也不应该在
web.xml
中的任何位置引用它。撤消所有操作(如果已完成)。您也不应该需要手动将其添加到 Eclipse 构建路径。只需放入/WEB-INF/lib
文件夹就足够了。另请参阅:
You need to drop JSTL JAR in
/WEB-INF/lib
or at least in the/lib
folder of the servletcontainer which you're using on local development.You should not extract the JAR and clutter the webapp with loose TLD files and also not reference it anywhere in
web.xml
. Undo everything if you have done it. You should also not have the need to manually add it to Eclipse build path. Just dropping in/WEB-INF/lib
folder ought to be enough.See also:
谷歌搜索没有返回任何有用信息的事实已经表明这个问题是我的配置所独有的。
唉,我终于弄清楚出了什么问题,我只是发布解决方案,以防有人遇到这个问题,这让我害怕了好几天。
结果我已经将 Tomcat 的 servlet-api.jar 和 jstl jar 添加到 Eclipse 的默认 JRE 库中,以避免每次都将它们添加到 WEB-INF\lib 中(即 Window > Preferences > Java > Installed JREs > Edit >添加外部罐子)。
当我开始在 GAE 中进行开发时,此配置开始导致与 AppEngine 自己的 servlet-api.jar 和 jstl jar 发生冲突。
答案很简单,就是从 JRE 库中删除 Tomcat jar。
The fact that google searches were returning no useful information already indicated that this problem was unique to my configuration.
Alas, I finally managed to figure out what was wrong and I'm just posting the solution in case someone comes across this problem, which dreaded me for days.
Turned out I had added Tomcat's servlet-api.jar and jstl jar into Eclipse's default JRE library to avoid having to add them each time into WEB-INF\lib (i.e. Window > Preferences > Java > Installed JREs > Edit > Add External Jar).
Once I started developing in GAE, this configuration started causing a conflict with AppEngine's own servlet-api.jar and jstl jars.
The answer was simply to remove the Tomcat jars from the JRE library.