1

我有以下代码:

RequestDispatcher dispatcher = getServletContext().getRequestDispatcher(address);
dispatcher.forward(req,res);

此代码的第二行在标题中产生错误。这是我的图书馆:

在此处输入图像描述

这是我的 pom.xml:

<dependencies>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-servlet-api</artifactId>
        <version>7.0.39</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-api</artifactId>
        <version>7.0.39</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-catalina</artifactId>
        <version>7.0.39</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-el-api</artifactId>
        <version>7.0.30</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-jasper-el</artifactId>
        <version>7.0.30</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc</artifactId>
        <version>3.59.81</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc_license_cu</artifactId>
        <version>3.59.81</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.ibm.db2</groupId>
        <artifactId>db2jcc_license_cisuz</artifactId>
        <version>3.59.81</version>
        <scope>provided</scope>
    </dependency>

</dependencies>

这是堆栈跟踪:

java.lang.NoClassDefFoundError: JspException
    java.lang.Class.getDeclaredMethods0(Native Method)
    java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
    java.lang.Class.privateGetPublicMethods(Class.java:2651)
    java.lang.Class.getMethods(Class.java:1467)
    java.beans.Introspector.getPublicDeclaredMethods(Introspector.java:1280)
    java.beans.Introspector.getTargetMethodInfo(Introspector.java:1141)
    java.beans.Introspector.getBeanInfo(Introspector.java:416)
    java.beans.Introspector.getBeanInfo(Introspector.java:163)
    org.apache.jasper.compiler.Generator$TagHandlerInfo.<init>(Generator.java:3957)
    org.apache.jasper.compiler.Generator$GenerateVisitor.getTagHandlerInfo(Generator.java:2212)
    org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1643)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    org.apache.jasper.compiler.Generator$GenerateVisitor.visit(Generator.java:1773)
    org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1539)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2452)
    org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:639)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
    org.apache.jasper.compiler.Node$Root.accept(Node.java:475)
    org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    org.apache.jasper.compiler.Generator.generate(Generator.java:3503)
    org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:250)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:373)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    MT_Servlet.gotoPage(MT_Servlet.java:160)
    MT_TasEntryServlet.doPost(MT_TasEntryServlet.java:1562)
    MT_TasEntryServlet.doGet(MT_TasEntryServlet.java:45)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    MT_Servlet.gotoPage(MT_Servlet.java:160)
    MT_TBLServletController.doPost(MT_TBLServletController.java:217)
    MT_TBLServletController.doGet(MT_TBLServletController.java:31)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)

有没有人看到这个问题?

4

2 回答 2

2

javax.servlet.JspException 包含在 jsp-api.jar 中(您也可以在此处找到包含 jars )。有关更多信息,请查看此答案

于 2013-10-21T20:24:54.127 回答
0

将 jsp-api.jar 从 tomcat lib 目录添加到您的类路径中。右键单击您的项目-属性-构建路径-添加外部jar-转到tomcat lib目录并选择jsp-api.jar。然后刷新您的项目。它现在应该删除此异常。

于 2013-10-21T20:43:10.173 回答