[英]JSTL breaks on GoogleAppEngine's development server, but works on remote server
As the title says, my JSTL tags don't work on my development server, but do work on Google's actual server. 如标题所示,我的JSTL标记在我的开发服务器上不起作用,但在Google的实际服务器上起作用。
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 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 我的配置如下(我认为是正确的并且可以在Google的服务器上运行):我正在使用
on web.xml 在web.xml上
However, I have also tried a number of combinations of the following and none of them worked: 但是,我也尝试了以下几种方法的组合,但均无效果:
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. 不过,奇怪的是,
<c:out value="${blah}"/>
在开发服务器和远程服务器上都可以工作。 other core tags don't work. 其他核心标签不起作用。 If I try to add fmt tags, they don't work as well.
如果我尝试添加fmt标签,它们也无法正常工作。
Any ideas? 有任何想法吗?
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. 您需要将JSTL JAR拖放到
/WEB-INF/lib
或至少放到您在本地开发中使用的servlet容器的/lib
文件夹中。
You should not extract the JAR and clutter the webapp with loose TLD files and also not reference it anywhere in web.xml
. 你不应该解压JAR和杂波松散TLD文件的Web应用程序,并也没有引用任何地方
web.xml
。 Undo everything if you have done it. 如果已完成,请撤消所有操作。 You should also not have the need to manually add it to Eclipse build path.
您也不需要手动将其添加到Eclipse构建路径。 Just dropping in
/WEB-INF/lib
folder ought to be enough. 只需放入
/WEB-INF/lib
文件夹就足够了。
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. finally,我终于设法弄清楚出了什么问题,我只是在发布解决方案,以防有人遇到这个问题,这困扰了我好几天。
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 (ie Window > Preferences > Java > Installed JREs > Edit > Add External Jar). 原来,我已经将Tomcat的servlet-api.jar和jstl jar添加到Eclipse的默认JRE库中,以避免每次都将它们添加到WEB-INF \\ lib中(即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. 一旦我开始在GAE中进行开发,此配置就会开始与AppEngine自己的servlet-api.jar和jstl jars产生冲突。
The answer was simply to remove the Tomcat jars from the JRE library. 答案很简单,就是从JRE库中删除Tomcat jar。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.