JavaWeb系统(增删改查多条件查询功能)
Posted MoooJL
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaWeb系统(增删改查多条件查询功能)相关的知识,希望对你有一定的参考价值。
一、应用名称:STD学生管理系统(Javaweb)
二、使用工具:mysqlr数据库,Eclipse软件
三、实现的功能:学生信息的增删改查、条件查询、模糊查询、精确查询等
四、步骤
1、在MySQL数据库新建student表
2、在Eclipse下新建web项目,并导入必要的jar包,下图是项目结构。
3、前端部分
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@page import="dao.UserDao,bean.User"%> <%@page import="java.util.ArrayList"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <link href="css/bootstrap.min.css" rel="stylesheet"> <script src="js/jquery-1.11.3.min.js" type="text/javascript"></script> <title>学生管理系统</title> </head> <script type="text/javascript"> function add() { location.href = "add.jsp"; } </script> <style> td { text-align: center; } .form-control { width: 90%; } </style> <body> <% Object message = request.getAttribute("message"); if(message!=null && !"".equals(message)){ %> <script type="text/javascript"> alert("<%=request.getAttribute("message")%>"); </script> <%} %> <% UserDao dao=new UserDao(); if(request.getAttribute("list") == null){ ArrayList<User> list = dao.getall(); request.setAttribute("list",list); } %> <table class="table table-hover table-striped table-bordered table-sm" id="resultshow"> <tr> <td colspan="6"> <h1>学生管理系统</h1> </td> </tr> <tr> <td colspan="3"> <button type="button" class="btn btn-info" onclick="add()">添加信息</button> </td> <td colspan="4" align="center"> <form action="Select" method="post"> <table> <tr> <td><input type="text" class="form-control" name="content"></td> <td><select name="way" class="form-control"> <option value="">--请选择查询方式--</option> <option value="1">学号</option> <option value="2">姓名</option> <option value="3">性别</option> <option value="4">住址</option> </select></td> <td > <button type="submit" class="btn btn-info">查询</button> </td> </tr> </table> </form> </td> </tr> <tr> <td>学号</td> <td>姓名</td> <td>性别</td> <td>出生年月</td> <td>住址</td> <td>操作</td> </tr> <c:forEach items="${list}" var="item"> <tr> <td>${item.sno}</td> <td>${item.sname}</td> <td>${item.ssex}</td> <td>${item.sbirthday}</td> <td>${item.saddress}</td> <td><a href="Delete?sno=${item.sno}" onclick = "return del()">删除</a> <a href="update?sno=${item.sno}">修改</a></td> </tr> </c:forEach> </table> </body> <script> //删除确认 function del() { if (!window.confirm(\'是否要删除数据??\')) return false; } </script> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>修改学生信息</title> </head> <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css"> <style> .container { width: 100%; height: 800px; position: relative; background: url("img/2.png") no-repeat center/cover; } .login { width: 500px; height: auto; background-color: white; position: absolute; top: 100px; left: 350px; border-radius: 8px; } label { float: left; width: 100px; margin-top: 7px; margin-right: 5px; } .form-control { width: 60%; } .logtip { padding-top: 20px; padding-bottom: 20px; border-bottom: 2px solid red; text-align: center; } .form-group { margin-left: 40px; margin-top: 40px; } .btn { height: 50px; width: 100px; float: left; border-radius: 10px; } .logbtn { margin-right: 20px; } .btnbag { margin-left: 140px; margin-right: 140px; height: 50px; overflow: hidden; margin-top: 30px; margin-bottom: 40px; } </style> <body> <div class="container"> <div class="login"> <h2 class="logtip">修改</h2> <form action="updatesave" method="post" onsubmit="return check()"> <div class="form-group"> <label for="sno">学号</label> <input type="text" class="form-control" id="sno" name="sno" value="${bean.sno}"> </div> <div class="form-group"> <label for="sname">姓名</label> <input type="text" class="form-control" id="sname" name="sname" value="${bean.sname}"> </div> <div class="form-group"> <label for="ssex">性别</label> <input type="text" class="form-control" id="ssex" name="ssex" value="${bean.ssex}"> </div> <div class="form-group"> <label for="sbirthday">出生年月</label> <input type="date" class="form-control" id="sbirthday" name="sbirthday" value="${bean.sbirthday}"> </div> <div class="form-group"> <label for="saddress">住址</label> <input type="text" class="form-control" id="saddress" name="saddress" value="${bean.saddress}"> </div> <div class="btnbag"> <input type="submit" class="btn btn-primary logbtn" value="确定"> <input type="reset" class="btn btn-primary mangbtn" value="重置"> </div> </form> </div> </div> </body> <script type="text/javascript"以上是关于JavaWeb系统(增删改查多条件查询功能)的主要内容,如果未能解决你的问题,请参考以下文章求一个基于javaWeb的超市管理系统,基本功能增删改查都要有,界面粗糙都没关系,谢谢
Elasticsearch全文检索技术 一篇文章即可从入门到精通(Elasticsearch安装,安装kibana,安装ik分词器,数据的增删改查,全文检索查询,聚合aggregations)(代码片