我有一个带有表单的 jsp 页面。
<form action="search.jsp" method="get">
<input type="submit" value="submit" />
</form>
在表单下方,我将有一个基于数据库查询的表。问题是,页面加载时会输出标题。是否可以等到按下提交按钮来运行查询/jsp?
<%
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("connection");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("query here);
%>
<h2>Something <% out.print(something); %> with something <% out.print(something); %> </h2>
<%
while (rs.next()) {
        output =rs.getString(1) + "  "  + rs.getString(2)  + " something "  + rs.getString(3) ;
        %>
        <tr>
        <td>  
        <%
        out.println(output);
       %>
       </td>
       </tr>           
       <%
}
con.close();
}
catch(Exception e) {
    System.out.println(e);
}
%>