Java web项目01 停车管理系统实现用户查询功能(三)
2017-12-11 15:29
489 查看
(一)查询界面
注:显示所有信息和显示查询信息的核心代码
效果演示:
<%@include file="/common/sub_header.jsp"%> <%@ page language="java" import="java.util.*,java.sql.*,com.biyeseng.db.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <link rel="stylesheet" type="text/css" href="css/common.css" /> <link rel="stylesheet" type="text/css" href="css/main.css" /> <script type="text/javascript" src="js/libs/modernizr.min.js"> </script> </head> <body> <jsp:include page="/top.jsp"></jsp:include> <jsp:include page="/left.jsp"></jsp:include> <!--/sidebar--> <div class="main-wrap"> <div class="crumb-wrap"> <div class="crumb-list"> <span class="crumb-name">用户管理</span> </div> </div> <div class="search-wrap"> <div class="search-content"> <form action="<%=path%>/userinfo/list.jsp" method="post"> <table class="search-tab"> <tr> <th width="150"> 请输入用户名称: </th> <td> <input class="common-text" placeholder="关键字" name="queryName" value="" id="" type="text"> </td> <td> <input class="btn btn-primary btn2" name="sub" value="查询" type="submit"> </td> </tr> </table> </form> </div> </div> <div class="result-wrap"> <form name="myform" id="myform" method="post"> <div class="result-title"> <div class="result-list"> <a href="<%=path%>/userinfo/addUserinfo.jsp"><i class="icon-font"></i>新增用户</a> </div> </div> <div class="result-content"> <table class="result-tab" width="100%"> <tr> <th> ID </th> <th> 用户名 </th> <th> 密码 </th> <th> 年龄 </th> <th> 电话 </th> <th> 卡余额 </th> <th> 操作 </th> </tr> <% DBManager dbm = new DBManager(); Connection conn = dbm.getConnection(); String queryName = request.getParameter("queryName"); String sql = "select * from userinfo"; //如果查询内容为空 if (queryName != null) { sql = "select * from userinfo where name like '%" + queryName + "%'"; } PreparedStatement pstmt = conn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { String id = rs.getString("id"); %> <tr> <td> <%=id%> </td> <td title=""> <%=rs.getString("name")%> </td> <td title=""> <%=rs.getString("pwd")%> </td> <td title=""> <%=rs.getString("age")%> </td> <td title=""> <%=rs.getString("tel")%> </td> <td title=""> <%=rs.getString("jine")%> </td> <td> <a class="link-update" href="<%=path%>/userinfo/modUserinfo.jsp?id=<%=id%>">修改</a> <a class="link-update" href="<%=path%>/userinfo/chong.jsp?id=<%=id%>">充值</a> <a class="link-del" href="<%=path%>/DelUserinfoAction?id=<%=id%>">删除</a> </td> </tr> <% } if (rs != null) rs.close(); if (pstmt != null) pstmt.close(); if (conn != null) conn.close(); %> </table> <div class="list-page"> </div> </div> </form> </div> </div> <!--/main--> </div> </body> </html>
注:显示所有信息和显示查询信息的核心代码
<% DBManager dbm = new DBManager(); Connection conn = dbm.getConnection(); String queryName = request.getParameter("queryName"); String sql = "select * from userinfo"; //如果查询内容为空 if (queryName != null) { sql = "select * from userinfo where name like '%" + queryName + "%'"; } PreparedStatement pstmt = conn.prepareStatement(sql); ResultSet rs = pstmt.executeQuery(); while (rs.next()) { String id = rs.getString("id"); %>
效果演示:
相关文章推荐
- Java web项目01 停车管理系统实现添加用户信息功能(四)
- Java web项目01 停车管理系统实现修改用户信息(五)
- Java web项目01 停车管理系统实现删除用户信息(六)
- java Web项目实践之7 添加功能、精确查询功能的设计及实现
- 笔记 Java web实现用户登录、数据库数据查询、数据删除等功能
- 01-php项目之雇员管理系统1-实现登录功能
- Java Web项目中实现文件下载功能的实例教程
- 【项目实战】select+input实现下拉框左右选择+模糊查询功能
- java web项目实现上传功能
- MYSQL实现排名及查询指定用户排名功能(并列排名功能)实例代码
- ThinkPHP框架实现用户信息查询更新及删除功能示例
- SSH框架网上商城项目第8战之查询和删除商品类别功能实现
- yii2项目实战-用户管理之登录与注册功能实现
- 实现Java Web项目分页功能
- yii2项目实战-用户管理之登录与注册功能实现
- jmeter学习—003——使用CSV Data Set Config参数化数据不重复的多次循环执行(实现多用户多笔投资不同项目功能)
- 【SSH网上商城项目实战08】查询和删除商品类别功能的实现
- 【SSH网上商城项目实战08】查询和删除商品类别功能的实现