out.print 出现在 HTML 标记之外

  • 本文关键字:HTML print out java html
  • 更新时间 :
  • 英文 :


我正在尝试从java中的循环打印,然后将其显示在html中。由于某种原因,印刷材料被写在桌子外面。

<table>
<%
...
while(rs.next()) {
    description = rs.getString("description");
    out.print("<tr bgcolor='#FFFFFF' class='style11'>" + description + "</tr>");
...
%>
</table>

似乎它应该可以工作,但生成的 html 文件如下所示:

description1description2
<table>
  <tbody>
      <tr class="style11" bgcolor="#ABCDEF"></tr>
      <tr class="style11" bgcolor="#ABCDEF"></tr>
  </tbody>
</table>

不是Java,而是HTML问题。你错过了<td>...</td>

<table>
<%
...
while(rs.next()) {
    description = rs.getString("description");
    out.print("<tr bgcolor='#FFFFFF' class='style11'><td>" + description + "</td></tr>");
...
%>
</table>

最新更新