Jetty 7高发行版,JSP和JSTL支持 [英] Jetty 7 hightide distribution, JSP and JSTL support

查看:107
本文介绍了Jetty 7高发行版,JSP和JSTL支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力尝试Jetty 7及其对JSP和JSTL的支持.

I've been struggling with Jetty 7 and its support for JSP and JSTL.

我的JSP文件:

<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<head>
  <title>blah</title>
</head>
<body>
  <table id="data">
    <tr class="columns">
      <td>Hour</td>
      <c:forEach var="campaign" items="${campaigns}">
        <td>${campaign}</td>            
      </c:forEach>
    </tr>

    <c:forEach var="hour" items="${results}">
      <tr>
        <td class="hour">${hour.key}</td>
        <c:forEach var="campaign" items="${campaigns}">
          <td>${hour[campaign]}</td>
        </c:forEach>            
      </tr>     
     </c:forEach>
  </table>  
</body>
</html>

上面的JSP部分按预期工作.但是,JSTL却没有.广告活动和结果变量是由Servlet设置的请求属性.

The JSP portions above work as expected. JSTL, however, does not. The campaigns and results variables are request attributes set by a servlet.

我收到以下错误:

WARN: ... compiler.TagLibraryInfoImpl: Unknown element (deferred-value) in attribute
WARN: ... compiler.TagLibraryInfoImpl: Unknown element (deferred-value) in attribute
WARN: ... compiler.TagLibraryInfoImpl: Unknown element (deferred-value) in attribute
ERROR: ... javax.servlet.ServletException: java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;

  • 我没有将任何jar文件捆绑到部署到码头的.war文件中.
  • 我正在使用的jetty版本是:jetty-hightide-7.0.1.v20091125
  • 类路径:

    /usr/local/jetty/lib/jetty-xml-7.0.1.v20091125.jar:/usr/local/jetty/lib/servlet-api-2.5.jar:/usr/local/jetty/lib/jetty-http-7.0.1.v20091125.jar:/usr/local/jetty/lib/jetty-continuation-7.0.1.v20091125.jar:/usr/local/jetty/lib/jetty-server-7.0.1.v20091125.jar:/usr/local/jetty/lib/jetty-security-7.0.1.v20091125.jar:/usr/local/jetty/lib/jetty-servlet-7.0.1.v20091125.jar:/usr/local/jetty/lib/jetty-webapp-7.0.1.v20091125.jar:/usr/local/jetty/lib/jetty-deploy-7.0.1.v20091125.jar:/usr/local/jetty/lib/jetty-servlets-7.0.1.v20091125.jar:/usr/local/jetty/lib/jsp/ant-1.6.5.jar:/usr/local/jetty/lib/jsp/core-3.1.1.jar:/usr/local/jetty/lib/jsp/jetty-jsp-2.1-7.0.1.v20091125.jar:/usr/local/jetty/lib/jsp/jsp-2.1-glassfish-9.1.1.B60.25.p2.jar:/usr/local/jetty/lib/jsp/jsp-api-2.1-glassfish-9.1.1.B60.25.p2.jar:/usr/local/jetty/resources:/usr/local/jetty/lib/jetty-util-7.0.1.v20091125.jar:/usr/local/jetty/lib/jetty-io-7.0.1.v20091125.jar
    

    任何帮助将不胜感激.

    预先感谢

    骗子.

    推荐答案

    java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
    

    此异常基本上意味着在运行时类路径中找不到所提及的方法,而在类或其依赖项之一的编译时类路径中却可以使用该方法.

    This exception basically means that the mentioned method cannot be found in the runtime classpath, while it was available in the compiletime classpath of either the class or one of its dependencies.

    JSP 2.1中引入了方法,该方法与Servlet 2.5紧密结合.由于Jetty 7应该支持Servlet 2.5,因此在这里就不用怀疑了,唯一的原因可能是web.xml被声明为Servlet 2.4或更低版本,而不是Servlet 2.5.因此,要解决此特定问题,您需要将web.xml声明为至少Servlet 2.5. <web-app>标签应如下所示:

    This method is introduced in JSP 2.1 which gets hand in hand with Servlet 2.5. Since Jetty 7 is supposed to support Servlet 2.5 and thus isn't the suspect here, the only cause can be that the web.xml is declared as Servlet 2.4 or lower instead of Servlet 2.5. So, to fix this particular problem, you need to declare your web.xml as at least Servlet 2.5. The <web-app> tag should look like this:

    <web-app 
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        id="YourWebAppID"
        version="2.5">
    

    如果这不能解决问题,那么另一个原因是/WEB-INF/lib甚至更糟的/JRE/lib/JRE/lib/ext都被包含较旧Servlet API版本的特定于应用程序服务器的库所困扰.例如.来自Tomcat的servlet-api.jar或来自Glassfish的j2ee.jarjavaee.jar等.您需要从任何不属于该库的库中清理这些类路径文件夹,因为它们在类加载中具有优先权,并将覆盖应用程序服务器自己的库.特定于应用程序服务器的库属于所讨论的应用程序服务器,而不属于webapp或JRE.

    If that doesn't solve the problem, then the other cause is that the /WEB-INF/lib or even worse the /JRE/lib or /JRE/lib/ext is cluttered with appserver-specific libraries containing an older Servlet API version. E.g. servlet-api.jar from Tomcat or j2ee.jar or javaee.jar from Glassfish, etcetera. You'll need to clean up those classpath folders from any libraries which doesn't belong there, because they get precedence in classloading and will override the appserver's own libraries. Appserver-specific libraries belongs to the appserver in question, not to the webapp or JRE.

    也就是说,除了实际问题之外,@page属性language="java" contentType="text/html; charset=utf-8"都是多余的. language已经默认为Java,contentType已经默认为text/html,并且如果将pageEncoding="UTF-8"设置为UTF-8,则会将charset设置为UTF-8.因此,以下内容已足够:

    That said and apart from the actual problem, the @page attributes language="java" contentType="text/html; charset=utf-8" are all superfluous. The language already defaults to Java and the contentType already defaults to text/html and the charset will already be set to UTF-8 if you set pageEncoding="UTF-8". So the following is already sufficient:

    <%@page pageEncoding="UTF-8" %>
    

    这篇关于Jetty 7高发行版,JSP和JSTL支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆