gpt4 book ai didi

gwt - 如何在 GWT 项目中使用 JSTL?

转载 作者:行者123 更新时间:2023-12-04 19:22:44 25 4
gpt4 key购买 nike

我正在构建一个 GWT 项目,使用 GWT-2.0.3 和 eclipse 插件。
好吧,首先我尝试了 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 的 jetty 服务器版本应该是 6.1,但我不确定,如果是这样,它应该支持 EE5,所以有人集成了 GWT 和 JSTL 吗?请帮忙!谢谢。

    最佳答案

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

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

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

    @Pascal:抱歉,我不是想说“切换到外部服务器,不说话”,只是我在 SO 和 GWT's Google Group 上看到了很多人。在配置 GWT 附带的 Jetty 时遇到问题 - 在某些情况下,这是因为配置与标准有些不同,因为 GWT 团队包含了旧的/修改过的(我无法获得有关此的任何可靠信息)版本的 Jetty,例如见 this post和那里的评论,一些引用:

    NOTE: I believe the version of jetty shipped with GWT is below 6.1.12 and therefore you must leave off the first parameter in the example docs as it was added in jetty 6.1.12rc3. See the note at the top of the Jetty documents page.



    Supposedly Jetty supports the servlet 2.5 specification and resource injection via the web.xml entry or @resource annotation. However, I have yet to figure out if this is supported by the Jetty version shipped with GWT. If anyone has figured out whether or not this works and if so how it is done please let me know.



    当有人想要使用 EJB 时会出现其他问题。

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

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

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com