弹出层界面<%--
Created by IntelliJ IDEA.
User: 29782
Date: 2024/5/15
Time: 20:42
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<link href="layui/css/layui.css" rel="stylesheet">
</head>
<style>
.demo-login-container{width: 320px; margin: 21px auto 0;}
.demo-login-other .layui-icon{position: relative; display: inline-block; margin: 0 2px; top: 2px; font-size: 26px;}
</style>
<script src="layui/layui.js"></script>
<script src="jQuery/jquery-1.7.2.js"></script>
<body>
<div style="padding: 20px" id="userid" lay-filter="userid">
<%-- <form class="layui-form" method="post" action="add">--%>
<div class="layui-form">
<div class="demo-login-container">
<div class="layui-form-item">
<div class="layui-input-wrap">
<div class="layui-input-prefix">
<i class="layui-icon layui-icon-username"></i>
</div>
<input type="text" name="id" id="id" value="" lay-verify="required" placeholder="学号" lay-reqtext="请填写学号" autocomplete="off" class="layui-input" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-wrap">
<div class="layui-input-prefix">
<i class="layui-icon layui-icon-username"></i>
</div>
<input type="text" name="name" id="name" value="" lay-verify="required" placeholder="姓名" lay-reqtext="请填写姓名" autocomplete="off" class="layui-input" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-wrap">
<div class="layui-input-prefix">
<i class="layui-icon layui-icon-username"></i>
</div>
<input type="text" name="sex" id="sex" value="" lay-verify="required" placeholder="姓名" lay-reqtext="请填写姓名" autocomplete="off" class="layui-input" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-wrap">
<input type="text" name="birthday" id="birthday" lay-affix="clear" placeholder="出生日期" class="layui-input"> </div>
</div>
</div>
</div>
<%-- </form>--%>
</div>
</body>
</html>
<%--
Created by IntelliJ IDEA.
User: 29782
Date: 2024/5/15
Time: 20:42
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<link href="layui/css/layui.css" rel="stylesheet">
</head>
<style>
.demo-login-container{width: 320px; margin: 21px auto 0;}
.demo-login-other .layui-icon{position: relative; display: inline-block; margin: 0 2px; top: 2px; font-size: 26px;}
</style>
<body>
<script src="layui/layui.js"></script>
<script src="jQuery/jquery-1.7.2.js"></script>
<div style="padding: 20px">
<form class="layui-form" method="post" action="add">
<div class="layui-form">
<div class="demo-login-container">
<div class="layui-form-item">
<div class="layui-input-wrap">
<div class="layui-input-prefix">
<i class="layui-icon layui-icon-username"></i>
</div>
<input type="text" name="id" id ="id" value="" lay-verify="required" placeholder="学号" lay-reqtext="请填写学号" autocomplete="off" class="layui-input" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-wrap">
<div class="layui-input-prefix">
<i class="layui-icon layui-icon-username"></i>
</div>
<input type="text" name="name" id="name" value="" lay-verify="required" placeholder="姓名" lay-reqtext="请填写姓名" autocomplete="off" class="layui-input" lay-affix="clear">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">单选框</label>
<div class="layui-input-block">
<input type="radio" name="sex" value="男" id="sex" title="男" checked>
<input type="radio" name="sex" value="女" id="sex1" title="女">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-wrap">
<input type="date" name="birthday" id="birthday" lay-affix="clear" placeholder="出生日期" class="layui-input"> </div>
</div>
</div>
</div>
</form>
</div>
</body>
</html>
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/edit")
public class edit extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException {
doPost(request,resp);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException {
String id=request.getParameter("id");
String name=request.getParameter("name");
String sex=request.getParameter("sex");
String birthday=request.getParameter("birthday");
Student student=new Student();
student.setId(id);
student.setName(name);
student.setSex(sex);
student.setBirthday(birthday);
Dao dao=new Dao();
dao.edit(student);
System.out.println(id+333);
resp.getWriter().write("success");
}
}
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/del")
public class del extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException {
String id=request.getParameter("id");
Dao dao=new Dao();
dao.del(id);
}
}
代码量 150行
时间 1小时