简体   繁体   English

JSTL在GoogleAppEngine的开发服务器上中断,但在远程服务器上可用

[英]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的服务器上运行):我正在使用

  • Eclipse IDE Eclipse IDE
  • Servlet 2.5 Servlet 2.5
  • No jstl jar added to WEB-INF\\lib 没有将jstl jar添加到WEB-INF \\ lib
  • No tld added anywhere 没有在任何地方添加TLD
  • No taglib reference 没有标签库参考

on web.xml 在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 jstl-1.2.jar添加到构建路径
  • c.tld added to WEB-INF c.tld添加到WEB-INF
  • taglib reference added to web.xml 添加到web.xml的taglib参考

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文件夹就足够了。

See also: 也可以看看:

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.

相关问题 远程Tomcat服务器上的JSTL破坏了webapp - JSTL on remote Tomcat server breaks webapp 在Java GoogleAppEngine开发服务器上显示日志消息(与GWT一起使用) - Making log messages visible on Java GoogleAppEngine development server (used with GWT) GoogleAppEngine:无法启动服务器-Jetty - GoogleAppEngine: couldn't start server - jetty 运行服务器时出现NoClassDefFoundError-GoogleAppEngine / Maven - NoClassDefFoundError when running server - GoogleAppEngine/Maven Tomcat servlet 在本地机器上工作,在服务器上中断 - Tomcat servlet works on local machine, breaks on server 在Eclipse上开发应用程序期间使用远程服务器 - use a remote server during the development of app on eclipse 代码在localhost上正常运行,但在远程服务器上却无法正常运行 - code works fine on localhost but not on remote server 适用于开发服务器,但不适用于Google App Engine(会话) - Works on development server but it doesn't on Google App Engine (Sessions) 端点:本地开发服务器返回500,但App Engine正常运行 - Endpoints: Local development server returns 500 but App Engine works fine 如何在Java程序(J2EE + JSTL)中获取服务器文件夹的路径 - how to get the path of server's folder inside Java program (J2EE + JSTL)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM