2 xiedijie6828 xiedijie6828 于 2017.01.13 15:22 提问

jsp连接mysql数据库将表中信息显示到页面中出现以下错误怎么解决

HTTP Status 500 - Unable to compile class for JSP:

type Exception report

message Unable to compile class for JSP:

description The server encountered an internal error that prevented it from fulfilling this request.

exception

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

An error occurred at line: 1 in the generated java file
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files

An error occurred at line: 1 in the generated java file
The type java.io.ObjectInputStream cannot be resolved. It is indirectly referenced from required .class files

An error occurred at line: 14 in the generated java file
Only a type can be imported. javassist.bytecode.stackmap.TypeData.ClassName resolves to a package

Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:469)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
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:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.30 logs.

Apache Tomcat/7.0.30

2个回答

xiedijie6828
xiedijie6828   2017.01.13 15:23

这是代码
<%@page import="javassist.bytecode.stackmap.TypeData.ClassName"%>
<%@ page language="java" contentType="text/html" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="java.sql.*" %>





<%!
public static final String DBdriver = "mysql.Driver";
public static final String url= "jdbc:mysql://localhost:3306/feedb";
public static final String user="root";
public static final String pass="zxcv";
%>
<%
Connection con=null;
PreparedStatement ps=null;
ResultSet rs=null;
%>
<%
try{
Class.forName(DBdriver);
con =DriverManager.getConnection(url,user,pass);
String sql ="select id,name,sex,age from fee";
ps=con.prepareStatement(sql);
rs=ps.executeQuery();
%>








<%
while(rs.next()){
int id=rs.getInt(1);
String name=rs.getString(2);
int age=rs.getInt(3);
String sex=rs.getString(4);
%>






<%
}
%>
id 姓名 年龄 性别
<%=id%> <%=name%> <%=age%> <%=sex%>


<%
}catch(Exception e){
System.out.println(e);
}finally{
rs.close();
ps.close();
con.close();
}
%>

xiangcaoyihan
xiangcaoyihan   2017.01.13 18:00

<%@ page language="java" contentType="text/html" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="javassist.bytecode.stackmap.TypeData.ClassName"%>
把jsp里的第一句和第二句调换一下, 另外注意你的import导入包路径是否正确

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!