我正在用GWT-2.0.3和eclipse插件构建一个GWT项目。
好吧,首先我尝试了JSTL1.2和Servlet 2.5,

  • 我确实将jSTL-1.2.jar添加到war/WEB-INF/lib
  • 我在web.xml中使用
  • :
    <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="WebApp_ID" version="2.5">
    
  • 在jsp页面中的
  • ,我使用:
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    
    <c:forEach var="app" items="${requestScope.apps}">
        <tr><td width=20%><c:out value="${app.mapping}"></c:out></td>
        <td width=40%><c:out value="${app.description}"></c:out></td>
        ...
    

  • 如果我删除了foreach标签,它可以正常工作。但是如果使用核心标签,则会出现以下异常:
    HTTP ERROR: 500
    
    javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
    RequestURI=/system/view/register.html
    
    Caused by:
    
    java.lang.AbstractMethodError: javax.servlet.jsp.PageContext.getELContext()Ljavax/el/ELContext;
        at javax.servlet.jsp.jstl.core.LoopTagSupport.unExposeVariables(LoopTagSupport.java:587)
        at javax.servlet.jsp.jstl.core.LoopTagSupport.doFinally(LoopTagSupport.java:323)
        at org.apache.jsp.system.view_jsp._jspx_meth_c_forEach_0(view_jsp.java:267)
        at org.apache.jsp.system.view_jsp._jspx_meth_a_body_0(view_jsp.java:186)
        at org.apache.jsp.system.view_jsp._jspService(view_jsp.java:98)
        at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
        at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
        at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
        at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:285)
        at org.mortbay.jetty.servlet.Dispatcher.forward(Dispatcher.java:126)
        at org.app4j.test.DispatchServlet.doGet(DispatchServlet.java:133)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
        at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
        at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
        at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
        at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:729)
        at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49)
        at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at org.mortbay.jetty.Server.handle(Server.java:324)
        at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:505)
        at org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:829)
        at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:513)
        at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:211)
        at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:380)
        at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
        at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:488)
    Powered by Jetty://
    

    如果我将项目部署到Tomcat 6,则可以正常工作。我在网上搜索,然后找到了"JSP Expression Language in GWT’s embedded Jetty"文章,所以我尝试了jSTL-1.1和servlet2.4,但仍然遇到该异常。

    我发现GWT的码头服务器版本应该是6.1,但我不确定,如果是真的,它应该支持EE5,所以有人集成了GWT和JSTL吗?请帮忙!谢谢。

    最佳答案

    我建议您仅切换到外部Java服务器(例如Tomcat,您似乎已经安装了它并且可以使用您的配置)-问题少得多,比尝试使用GWT附带的残缺Jetty容易。

    可以在docs中找到说明。如果您坚持使用GWT的码头,那么将来只会遇到更多问题。

    更新,请参阅下面Pascal Thivent的评论:

    @Pascal:对此感到抱歉,我并不是要说“切换到外部服务器,不要说话”,只是我在SO和GWT's Google Group上看到很多人在配置GWT附带的Jetty时遇到问题-在某些情况下,这是因为配置与标准配置有所不同,因为GWT团队包含了较旧的/修改后的(我对此无法获得任何可靠信息)版本的Jetty,例如,请参阅this post和其中的注释,并带有一些引号:





    当某人想要使用EJB时​​,还会发生其他问题。

    所有这些(也许以一种更简洁/神秘的方式)都写在GWT的文档中-我在上面提供了一个链接到指向解决此问题的确切段落。
    希望可以解决一些问题-切换到外部服务器似乎是最简单,最简单和最好的解决方案-无需“特殊GWT”配置,这意味着您可以使用生产环境中使用的相同配置/服务器,而无需需要将您的配置迁移到例如Tomcat,迁移后没有意外错误等。

    关于gwt - 如何在GWT项目中使用JSTL?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2364129/

    10-12 07:33
    查看更多