如何在GWT项目中使用JSTL? [英] How to use JSTL in a GWT project?
问题描述
我正在用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_IDversion =2.5>
-
在jsp页面中,我使用:
<%@ taglib uri =http://java.sun.com/jsp/jstl/coreprefix =c%>
< c:forEach var =appitems =$ {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错误:500
javax.servlet.jsp.PageContext.getELContext()Ljavax / EL / ELContext;
RequestURI = / system / view / register.html
原因:
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)
在org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
在org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
在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)在org.app4j.test.DispatchServlet.doGet(DispatchServlet.java:133)
在javax.servlet.http.HttpServlet.service(HttpServlet.java:707)$在javax.servlet.http.HttpServlet.service b $ b(HttpServlet.java:820)
在org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:487)
。在组织。 mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:362)
at org.mortbay.jetty.security。 SecurityHandler.handle(SecurityHandler.java:216)
在org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
在org.mortbay.jetty.handler.ContextHandler.handle( ContextHandler.java:729)
在org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:405)
在org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:在org.mortbay.jetty.handler.RequestLogHandler.handle(RequestLogHandler.java:49 152)
)
。在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。 $(HttpConnection.java:380)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:395)
at org.mortbay.thread.QueuedThreadPool $ PoolThread.run(QueuedThreadPool。如果我把这个项目部署到Tomcat上,那么这个项目就是Tomcat的一部分了。 6,它工作正常。我在网上搜索,并找到一篇文章,GWT嵌入式Jetty中的JSP表达式语言,所以我尝试了jstl-1.1和servlet2.4,但我仍然得到这个异常。
-
我发现GWT的jetty服务器版本应该是6.1,但我不确定,如果那是真的,它应该支持EE5,所以任何人都集成了GWT和JSTL?请帮忙!感谢。解决方案当我在为我的应用引擎项目寻找修复JSTL时,我偶然发现了这个问题。我在google上找到了Will It Play的答案。显然你必须添加
<%@ page isElIgnored =false%>
到您的JSP页面以启用EL解析。
i am building a GWT project, with GWT-2.0.3 and eclipse plugin.
well, first i tried, JSTL1.2 and servlet 2.5,
- 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">
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>
...
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://
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.
解决方案 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" %>
to your JSP pages to enable EL parsing.
这篇关于如何在GWT项目中使用JSTL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!