• Java web find_stu_3.jsp


    <%@ page contentType="text/html" pageEncoding="UTF-8" import="java.sql.*"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>由提交页面获取查询条件并实现查询的页面</title>
    </head>
    <body>
    <center>
    <%
    request.setCharacterEncoding("UTF-8");
    String driverName= "com.mysql.jdbc.Driver";
    String userName="root";
    String userPwd="147258369";
    String dbName="students";
    String url1="jdbc:mysql://localhost:3306/"+dbName;
    String url2="?user="+userName+"&password="+userPwd;
    String url3="&useUnicode=true&characterEncoding=UTF-8";
    String url=url1+url2+url3;
    Class.forName(driverName);
    Connection conn=DriverManager.getConnection(url);

    String sex=request.getParameter("sex");
    float weight1=Float.parseFloat(request.getParameter("w1"));
    float weight2=Float.parseFloat(request.getParameter("w2"));
    String sql="select * from students_info where sex=? and weight>=? and weight<=?";
    PreparedStatement pstmt=conn.prepareStatement(sql);
    pstmt.setString(1,sex);
    pstmt.setFloat(2,weight1);
    pstmt.setFloat(3,weight2);
    ResultSet rs=pstmt.executeQuery();
    rs.last();
    %>你要查询的学生数据表中共有
    <font size="5" color="red"> <%=rs.getRow()%></font>人
    <table border="2" bgcolor="ccceee" width="650">
    <tr bgcolor="CCCCCC" align="center">
    <td>记录条数</td> <td>学号</td> <td>姓名</td>
    <td>性别</td> <td>年龄</td><td>体重</td><td>身高</td>
    </tr>
    <% rs.beforeFirst();
    while(rs.next()){
    %> <tr align"center">
    <td><%=rs.getRow() %>
    <td><%=rs.getString("id") %></td>
    <td><%=rs.getString("name") %></td>
    <td><%=rs.getString("sex") %></td>
    <td><%=rs.getString("age") %></td>
    <td><%=rs.getString("weight") %></td>
    <td><%=rs.getString("hight") %></td>
    </tr>
    <% } %>
    </table>
    </center>
    <%if(rs!=null){ rs.close();}
    if(pstmt!=null){pstmt.close();}
    if(conn!=null){conn.close();}
    %>
    </body>
    </html>

  • 相关阅读:
    Python神库分享之geoip2 IP定位库
    科普一下推荐引擎
    浏览器插件之王-Tampermonkey(油猴脚本)
    Swagger入门教程
    使用SonarQube+Eclipse来分析python代码
    什么是搜索引擎蜘蛛?
    让所有网站都提供API的Python库:Toapi
    如何提高自己的逻辑思维能力?
    推荐系统和搜索引擎的关系
    html 后台页面布局
  • 原文地址:https://www.cnblogs.com/meng2/p/7732779.html
Copyright © 2020-2023  润新知