【发布时间】:2015-07-14 08:40:34
【问题描述】:
我有下面的 JSP
<table>
<thead>
<th>Patient ID</th>
<th>Name</th>
<th>Address</th>
<th>Contact No</th>
<th>Disease</th>
<th>Doctor Assigned</th>
<th>Date</th>
<th>Room Assigned</th>
</thead>
<%
String Query = "Select ID, Name, address, contactnumber,disease,DOCASSIGN,JOINING, ROOMASSIGN from patient";
PreparedStatement ps = conn.prepareStatement(Query);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
%>
<tr>
<td>
<%
out.print(rs.getInt(1));
%>
</td>
<td>Hi</td>
</tr>
<%
}
%>
</table>
我正在运行查询并将数据放入表td。查询运行良好,问题是如果我使用<td><%out.print(rs.getInt(1));%></td>,则该值显示在td 中,但是当我尝试使用<td><%rs.getInt(1);%></td> 获取它时,td 显示为空白。
我想知道如果在jsp中,显示值,我们必须使用out.print(),或者我可以直接使用<td><%rs.getInt(1);%></td>显示值。
【问题讨论】: