Unable to compile class for JSP的解决办法

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/Fly000h/article/details/80854296

在学习Tomcat的过程中,部署完项目,打开后遇到如图所示情况:

错误提示:不能编译一个类。

打开对应的JSP ,在文件头的导入部分:

改为:

<%@ page import="javax.naming.*,java.sql.*,javax.sql.*" %>

即可~

展开阅读全文

Unable to compile class for JSP 求救

02-17

(1)网页文件mytest.jsprn<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>rnrnrnrn rn ACCESS连接测试rnrnrn<%rntryrn Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");rnrncatch(ClassNotFoundException e)rn out.print(e);rnrntryrn String url = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=F:\wordspace\myproject1\Database.mdb";rn //其中 E:/javatest/AccessDb/test.mdb 为数据库所在绝对路径rnrn //建立ODBC数据源连接rn Connection conn = DriverManager.getConnection(url);rn Statement stmt = conn.createStatement();rn ResultSet rs = stmt.executeQuery("SELECT * FROM table"); //取得table表中的记录rn out.println("Table-list"+" ");rn while(rs.next())rn out.print(rs.getInt(1)+" ");rn out.print(rs.getString(2)+" ");rn rn rs.close();rn stmt.close();rn conn.close();rnrncatch(Exception ex)rn out.print(ex);rnrn%>rnrnrn(2)在IE6浏览器中打开这个JSP,结果报错如下:rnorg.apache.jasper.JasperException: Unable to compile class for JSPrnrnAn error occurred at line: 9 in the jsp file: /mytest.jsprnrnGenerated servlet error:rn [javac] Compiling 1 source filernrnC:\Documents and Settings\Administrator\.IntelliJIdea80\system\tomcat\Unnamed_wordspace723ee4b1\work\Catalina\localhost\myproject1\org\apache\jsp\mytest_jsp.java:59: illegal escape characterrnrnrnrnAn error occurred at line: 9 in the jsp file: /mytest.jsprnrnGenerated servlet error:rn String url = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=F:\wordspace\myproject1\Database.mdb";rn ^rnrnrnrnAn error occurred at line: 9 in the jsp file: /mytest.jsprnrnGenerated servlet error:rnC:\Documents and Settings\Administrator\.IntelliJIdea80\system\tomcat\Unnamed_wordspace723ee4b1\work\Catalina\localhost\myproject1\org\apache\jsp\mytest_jsp.java:59: illegal escape characterrnrnrnrnAn error occurred at line: 9 in the jsp file: /mytest.jsprnrnGenerated servlet error:rn String url = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=F:\wordspace\myproject1\Database.mdb";rn ^rnrnrnrnAn error occurred at line: 9 in the jsp file: /mytest.jsprnrnGenerated servlet error:rnC:\Documents and Settings\Administrator\.IntelliJIdea80\system\tomcat\Unnamed_wordspace723ee4b1\work\Catalina\localhost\myproject1\org\apache\jsp\mytest_jsp.java:59: illegal escape characterrnrnrnrnAn error occurred at line: 9 in the jsp file: /mytest.jsprnrnGenerated servlet error:rn String url = "jdbc:odbc:driver=Microsoft Access Driver (*.mdb);DBQ=F:\wordspace\myproject1\Database.mdb";rn ^rn3 errorsrnrnrn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)rn org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:553)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:856)rnrn请大家帮找下究竟是什么原因,谢谢! 论坛

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

08-22

HTTP Status 500 -rnrntype Exception reportrnrnmessagernrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexceptionrnrnorg.apache.jasper.JasperException: Unable to compile class for JSP: rnrnAn error occurred at line: 108 in the jsp file: /AddressBook/b_nameall.jsprnThe method adreesName(String) is undefined for the type AddressDaorn105: String birthday=request.getParameter("birthday");rn106: String phone=request.getParameter("phone");rn107: name=new String(request.getParameter("name").getBytes("iso-8859-1"),"gb2312");rn108: ArrayList aList1=aDao.adreesName(name);rn109: %>rn110: rn111: <%rnrnrnStacktrace:rn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)rn org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:317)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:295)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:282)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:586)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:717)rnnote The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.rnrnrnrn这个错是怎么样造成的。我这么找都找不到。 论坛

急,Unable to compile class for JSP

09-09

代码没有问题,在别的机器可运行,在新机器上部署就出问题了,是个登陆页面,登陆后显示错误rnrntype Exception reportrnrnmessage rnrndescription The server encountered an internal error () that prevented it from fulfilling this request.rnrnexception rnrnorg.apache.jasper.JasperException: Unable to compile class for JSPrnrnAn error occurred at line: 65 in the jsp file: /login_do.jsprnGenerated servlet error:rnD:\tool\New Folder\tomcat\tomcat\webapps\RBT\work\org\apache\jsp\login_005fdo_jsp.java:121: unreachable statementrn out.write("\r\n");rn ^rn1 errorrnrnrnrn org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)rn org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:332)rn org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:412)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:472)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:451)rn org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)rn org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)rn org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:295)rn org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)rn org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)rn javax.servlet.http.HttpServlet.service(HttpServlet.java:802)rnrnrnnote The full stack trace of the root cause is available in the Apache Tomcat/5.0.28 logs.rnrn 论坛

没有更多推荐了,返回首页