如何在 GWT 项目中使用 JSTL? [英] How to use JSTL in a GWT project?
问题描述
我正在构建一个 GWT 项目,使用 GWT-2.0.3 和 eclipse 插件.好吧,我首先尝试了 JSTL1.2 和 servlet 2.5,
i am building a GWT project, with GWT-2.0.3 and eclipse plugin. well, first i tried, JSTL1.2 and servlet 2.5,
- 我确实将 jstl-1.2.jar 添加到 war/WEB-INF/lib
在 web.xml 中,我使用:
- i do add jstl-1.2.jar to war/WEB-INF/lib
in web.xml, i use:
<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页面中,我使用:
in the jsp page, i use:
<%@ 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 标签,它工作正常.但是如果我使用核心标签,我会得到以下异常:
If I remove the foreach tag, it works fine. but if I use the core tags, I get the following exception:
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,它工作正常.我在网上搜索,我找到了一篇文章,"GWT 的嵌入式 Jetty 中的 JSP 表达式语言",所以我尝试了 jstl-1.1 和 servlet2.4,但我仍然遇到该异常.
我发现GWT的jetty服务器版本应该是6.1,但我不确定,如果是真的,它应该支持EE5,所以有人集成了GWT和JSTL吗?请帮忙!谢谢.
If i deploy the project to Tomcat 6, it works fine. i search on the web, and i find a article, "JSP Expression Language in GWT’s embedded Jetty", so i tried jstl-1.1 and servlet2.4, but i still get that exception.
i find the GWT's jetty server version should be 6.1, but i am not sure about it, if that is true, it should support EE5, so any one has integrated GWT and JSTL? please help! thanks.
推荐答案
我在为我的应用引擎项目寻找修复 JSTL 时偶然发现了这个问题.我在谷歌的Will It Play"页面上找到了答案.显然你必须添加
I stumbled on this while I was looking for fix JSTL for my app engine project. I found the answer on "Will It Play" page by google. Apparently you have to add
<%@page isElIgnored="false" %>
到您的 JSP 页面以启用 EL 解析.
to your JSP pages to enable EL parsing.
这篇关于如何在 GWT 项目中使用 JSTL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!