<%@page contentType="text/html;charset=gbk"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<html>
<head>
<title>
sql
<title>
</head>
<body>
<sql:setDataSource url="jdbc:mysql://localhost:3306/student" driver="com.mysql.jdbc.Driver" user="root" password="zlj" var="ds"/>
<sql:query sql="select * from stu" var="result" dataSource="${ds}"/>
<table border="1">
<tr>
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
<th>生日</th>
</tr>
<c:forEach var="row" items="%{result.rows}">
<tr>
<td><c:out value="${row.id}"/></td>
<td><c:out value="${row.name}"/></td>
<td><c:out value="${row.age}"/></td>
<td><c:out value="${row.brithday}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>
Exception :org.apache.jasper.JasperException: An exception occurred processing JSP page /sqlQuery.jsp at line 2421: <c:forEach var="row" items="%{result.rows}">
22: <tr>
23:
24: <td><c:out value="${row.name}"/></td>
25: <td><c:out value="${row.age}"/></td>
26: <td><c:out value="${row.brithday}"/></td>
27: </tr>root cause javax.el.PropertyNotFoundException: Property 'name' not found on type java.lang.String
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<html>
<head>
<title>
sql
<title>
</head>
<body>
<sql:setDataSource url="jdbc:mysql://localhost:3306/student" driver="com.mysql.jdbc.Driver" user="root" password="zlj" var="ds"/>
<sql:query sql="select * from stu" var="result" dataSource="${ds}"/>
<table border="1">
<tr>
<th>编号</th>
<th>姓名</th>
<th>年龄</th>
<th>生日</th>
</tr>
<c:forEach var="row" items="%{result.rows}">
<tr>
<td><c:out value="${row.id}"/></td>
<td><c:out value="${row.name}"/></td>
<td><c:out value="${row.age}"/></td>
<td><c:out value="${row.brithday}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>
Exception :org.apache.jasper.JasperException: An exception occurred processing JSP page /sqlQuery.jsp at line 2421: <c:forEach var="row" items="%{result.rows}">
22: <tr>
23:
24: <td><c:out value="${row.name}"/></td>
25: <td><c:out value="${row.age}"/></td>
26: <td><c:out value="${row.brithday}"/></td>
27: </tr>root cause javax.el.PropertyNotFoundException: Property 'name' not found on type java.lang.String
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货