jsp+jstl问题:以下代码哪个地方错了,麻烦网友帮忙看下。对于ResultSet集合我试了,能遍历出来,加分 10
<body><%ResultSetrs=null;Connectionconn=null;Statementst=null;request.setCharacterEnc...
<body>
<%
ResultSet rs=null;
Connection conn=null;
Statement st=null;
request.setCharacterEncoding("utf-8");
try{
Class.forName("com.mysql.jdbc.Driver");
String s="jdbc:mysql://localhost:3306/po?useUnicode=true&characterEncoding=UTF-8";
conn=DriverManager.getConnection(s,"root","csf123");
st=conn.createStatement();
rs=st.executeQuery("SELECT * FROM resident WHERE rhost LIKE'王%'");
}catch(Exception e){
e.printStackTrace();
}
request.setAttribute("ss",rs );
%>
<table border="1">
<tr>
<td>序号</td>
<td>户口编号</td>
<td>住址</td>
<td>户主姓名</td>
<td>入户日期</td>
<td>本户人数</td>
</tr>
<c:forEach items="${requestScope.ss}" var="i">
<tr>
<td>${i[1]}</td>
</tr>
</c:forEach>
</table>
</body>
当去掉:
<c:forEach items="${requestScope.ss}" var="i">
<tr>
<td>${i[1]}</td>
</tr>
</c:forEach>
这一段的时候其他代码运行正常 展开
<%
ResultSet rs=null;
Connection conn=null;
Statement st=null;
request.setCharacterEncoding("utf-8");
try{
Class.forName("com.mysql.jdbc.Driver");
String s="jdbc:mysql://localhost:3306/po?useUnicode=true&characterEncoding=UTF-8";
conn=DriverManager.getConnection(s,"root","csf123");
st=conn.createStatement();
rs=st.executeQuery("SELECT * FROM resident WHERE rhost LIKE'王%'");
}catch(Exception e){
e.printStackTrace();
}
request.setAttribute("ss",rs );
%>
<table border="1">
<tr>
<td>序号</td>
<td>户口编号</td>
<td>住址</td>
<td>户主姓名</td>
<td>入户日期</td>
<td>本户人数</td>
</tr>
<c:forEach items="${requestScope.ss}" var="i">
<tr>
<td>${i[1]}</td>
</tr>
</c:forEach>
</table>
</body>
当去掉:
<c:forEach items="${requestScope.ss}" var="i">
<tr>
<td>${i[1]}</td>
</tr>
</c:forEach>
这一段的时候其他代码运行正常 展开
2个回答
展开全部
<c:forEach items="${ss}" var="i">
<tr>
<td>${i[1]}</td>
</tr>
</c:forEach>
试试这种能行不
<tr>
<td>${i[1]}</td>
</tr>
</c:forEach>
试试这种能行不
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询