我正在尝试使用 jsp 检索数据,但它显示 Error:org.apache.jasper.JasperException: An exception occurred processing JSP page /databaseTest.jsp at line 13
我的代码是:
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.io.*,java.util.*,java.sql.*" %>
<%@page import="javax.servlet.http.*,javax.servlet.*" %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSTL sql:query Tag</title>
</head>
<body>
<sql:setDataSource var="ds" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/JSPTUTORIAL"
user="root" password="root"/>
<sql:query dataSource="${ds}" var="result">
SELECT * FROM Employees;
</sql:query>
<h4>Employee Table</h4>
<table border="1" width="100%">
<tr>
<th>Employee ID</th>
<th>First Name</th>
<th>Last Name</th>
<th>Age</th>
</tr>
<c:forEach var="row" items="${result.rows}"/>
<tr>
<td><c:out value="${row.id}"/></td>
<td><c:out value="${row.first}"/></td>
<td><c:out value="${row.last}"/></td>
<td><c:out value="${row.age}"/></td>
</tr>
</table>
</body>