为什么我在tokem""上收到语法错误,在我的JSP中删除此标记?

时间:2014-07-16 11:07:51

标签: jsp servlets scriplets

我正在尝试将db表数据检索到表中,但我在

处收到语法错误
<body>
      <tr>
         if(!resultset.next()) {
              out.println("Sorry, could not find that publisher. ");
           } else {     
            while(resultset.next())
            {
            <tr>
            <td class="auto-style9"><%=resultset.getInt(1)%> </td> 
            <td class="auto-style10"><%=resultset.getString(2)%></td>
            <td class="auto-style11"><%=resultset.getString(3)%></td>
            <td class="auto-style11"><%=resultset.getString(4)%></td>
        </tr>   
            }
           } 
     %>
      </table>
</body>

1 个答案:

答案 0 :(得分:1)

您将html代码与jsp代码混合在一起。

应该是:

<%
if(!resultset.next()) {
    out.println("Sorry, could not find that publisher. ");
} else {
    while(resultset.next())
    {
%>
    <tr>
        <td class="auto-style9"><%=resultset.getInt(1)%> </td> 
        <td class="auto-style10"><%=resultset.getString(2)%></td>
        <td class="auto-style11"><%=resultset.getString(3)%></td>
        <td class="auto-style11"><%=resultset.getString(4)%></td>
    </tr>
<%
    }
} 
%>
</table>