【问题标题】:Error when trying to redirect from servlet to JSP page with Parameters尝试使用参数从 servlet 重定向到 JSP 页面时出错
【发布时间】:2014-01-24 10:10:12
【问题描述】:

尝试使用参数从 servlet 重定向到 JSP 页面时出错:

我的 Servlet 代码如下:

       String name = "Test";
       request.setAttribute("name", name);
       RequestDispatcher view = request.getRequestDispatcher("/page.jsp");
       view.forward(request, response);

JSP页面如下:

<!doctype html>
<html lang="en">
    <head>
        <title>SO question 2370960</title>
    </head>
    <body>
         <p>Message: ${name}</p>
    </body>
</html> 

我收到以下错误:

 Jan 24, 2014 12:05:35 PM org.apache.jasper.runtime.JspFactoryImpl internalGetPageContext
 SEVERE: Exception initializing page context
 java.lang.NoClassDefFoundError: javax/el/StaticFieldELResolver
 at        org.apache.jasper.runtime.JspFactoryImpl.internalGetPageContext(JspFactoryImpl.java:172)
at org.apache.jasper.runtime.JspFactoryImpl.getPageContext(JspFactoryImpl.java:123)
at org.apache.jsp.captcha_jsp._jspService(captcha_jsp.java:34)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:411)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:473)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:377)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
... 35 more

请帮忙。

【问题讨论】:

标签: java jsp servlets


【解决方案1】:

安装新版 TomCat

ServletContext context = getServletContext();
RequestDispatcher rd = context.getRequestDispatcher("/page.jsp");
rd.forward(request, response);

确保路径正确

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-27
    • 2015-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-13
    相关资源
    最近更新 更多