org.apache.jasper.JasperException:无法为JSP编译类:

时间:2015-03-27 10:14:10

标签: java html jsp maven servlets

我是servlet jsp的初学者我的pom.xml就像我在apache tomcat 7.0.57中运行它时得到的错误

错误我得到了 类型异常报告

message无法为JSP编译类:

说明服务器遇到内部错误,导致无法完成此请求。

例外     org.apache.jasper.JasperException:无法为JSP编译类:

An error occurred at line: [32] in the generated java file: [C:\apache-tomcat-7.0.57\work\Catalina\localhost\deltaWebServices\org\apache\jsp\index_jsp.java]
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:485)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

POM.xml看起来像这样

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
    <artifactId>utilities</artifactId>
    <groupId>com.here.utilities</groupId>
    <version>15.01.silver_mum1-SNAPSHOT</version>
    <relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>come.here</groupId>
<artifactId>deltaWebServices</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>deltaWebServices</name>
<url>http://maven.apache.org</url>
<dependencies>

    <!-- <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-server</artifactId>
        <version>1.19</version>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-core</artifactId>
        <version>1.19</version>
    </dependency>

    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-bundle</artifactId>
        <version>1.19</version>
    </dependency>

     -->
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>

     <dependency>
        <groupId>com.navteq</groupId>
        <artifactId>mapcore</artifactId>
        <version>arn.carbon-SNAPSHOT</version>
    </dependency>



</dependencies>
<build>
    <finalName>deltaWebServices</finalName>
</build>

我的index.jsp是

<%@ page language="java" contentType="text/html; charset=windows-1256"
pageEncoding="windows-1256"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">`<%@ page import="come.here.webservices.*"%>`<html><body>`<form action="deltaWebServices/come.here.webservices.ConfigServlet">
    <table>
        <tr>
            <td>Please Enter Workspace</td>
            <td><input type="text" name="Workspace" /></td>

        </tr>
        <tr>
            <td>Please Enter region</td>
            <td><input type="text" name="region" /></td>

        </tr>
        <tr>
            <td>Please Enter Rule</td>
            <td><input type="text" name="rule" /></td>

        </tr>

        <tr>

            <td><input type="submit" value="submit" /></td>

        </tr>

    </table>
</form>`</body></html>`

我的配置servlet是

package come.here.webservices;

 import java.io.IOException;
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;

 import org.hsqldb.server.Servlet;

 /**
 * Servlet implementation class ConfigServlet
 */
public class ConfigServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

 /**
 * @see HttpServlet#HttpServlet()
 */
public ConfigServlet() {
    super();
    // TODO Auto-generated constructor stub
}

/**
 * @see Servlet#init(ServletConfig)
 */
public void init(ServletConfig config) {
    // TODO Auto-generated method stub
}

/**
 * @see Servlet#destroy()
 */
public void destroy() {
    // TODO Auto-generated method stub
}

/**
 * @see Servlet#getServletConfig()
 */
public ServletConfig getServletConfig() {
    // TODO Auto-generated method stub
    return null;
}

/**
 * @see Servlet#getServletInfo()
 */
public String getServletInfo() {
    // TODO Auto-generated method stub
    return null;
}

/**
 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse
 *      response)
 */
protected void service(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
 *      response)
 */
public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    // TODO Auto-generated method stub
    ConfigBean config = new ConfigBean();
    config.setWorkspace(request.getParameter("Workspace"));
    config.setRegion(request.getParameter("region"));
    config.setRule(request.getParameter("rule"));
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
 *      response)
 */
public void doPost(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    // TODO Auto-generated method stub
    ConfigBean config = new ConfigBean();
    config.setWorkspace(request.getParameter("Workspace"));
    response.sendRedirect("Added.jsp");
}

}

web.xml是

<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
<display-name>Archetype Created Web Application</display-name>

<servlet>
    <servlet-name>ConfigServlet</servlet-name>
    <servlet-class>come.here.webservices.ConfigServlet.class</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>ConfigServlet</servlet-name>
    <url-pattern>/deltaWebServices/come.here.webservices.ConfigServlet</url-pattern>
</servlet-mapping>
</web-app>

错误是:

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: [32] in the generated java file: [C:\apache- tomcat-7.0.57\work\Catalina\localhost\deltaWebServices\org\apache\jsp\index_jsp.java]
The method getJspApplicationContext(ServletContext) is undefined for the type JspFactory

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:103)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:366)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:485)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:379)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:341)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:657)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

1 个答案:

答案 0 :(得分:0)

在JSP中,我在页面底部发现了一些代码工件为'(单引号):

</form>`</body></html>`

尝试清除并检查它。