<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
try{
try{
Class.forName("com.mysql.cj.Driver");
}catch(Exception e){out.println(e);}
Connect con=DriverManager.getConnect("localhost","root","root");
String sql="select * from user where id=?";
//调试方法1:(就在本页执行,下面的代码不要有任何的页面跳转的代码,否则看不到改页的出错信息),看页面输出的错误信息
out.println(request.getParameter("id"));
PrepareStatment prepareStatement= con.prepareStatement(sql);
prepareStatement.setInt(1,Integer.parseInt(request.getParameter("id")));
//调试方法2,觉得改代码prepareStatement.executeQuery();有问题,可以使用try()catch{}
try{
prepareStatement.executeQuery();
}catch(Exception e){
out.println(e.toString());
}
}catch(Exception e){
out.println("这是调试页面的报错信息")
//out.println(e.toString());
}
%>
<%
//调试过程请将改代码注释,页面跳转就看不到报错信息了
//response.sendRedirect("success.jsp");
%>
</body>
</html>
记事本调试javaWeb程序
猜你喜欢
转载自blog.csdn.net/qq_41063141/article/details/89276724
今日推荐
周排行