10.19

对于web的实验进行了一个应用layui框架和jQuery的登录注册界面和查看个人信息界面

<%--
Created by IntelliJ IDEA.
User: 29782
Date: 2024/5/15
Time: 20:38
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Demo</title>
<!-- 请勿在项目正式环境中引用该 layui.css 地址 -->
<link href="layui/css/layui.css" rel="stylesheet">
<style>
.layui-btn-container .layui-btn {
margin-right: 93px; /* 或者您想要的任何间距值 */
}
</style>
</head>
<body>
<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>
<form class="layui-form" method="post" action="login">
<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="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-password"></i>
</div>
<input type="password" name="password" value="" lay-verify="required" placeholder="密 码" lay-reqtext="请填写密码" autocomplete="off" class="layui-input" lay-affix="eye">
</div>
</div>
<div class="layui-form-item">
<input type="checkbox" name="remember" lay-skin="primary" title="记住密码">
<a href="#forget" style="float: right; margin-top: 7px;">忘记密码?</a>
</div>
<div class="layui-form-item">
<div class="layui-btn-container">
<button type="submit" class="layui-btn" >登录</button>
<a href="register.jsp" class="layui-btn">注册</a>
</div>
</div>
</div>
</form>

<!-- 请勿在项目正式环境中引用该 layui.js 地址 -->
<script src="layui/layui.js"></script>
<script>
layui.use(function(){
var form = layui.form;
var layer = layui.layer;
// 提交事件
form.on('submit(demo-login)', function(data){
var field = data.field; // 获取表单字段值
// 显示填写结果,仅作演示用
// 此处可执行 Ajax 等操作
// …
return false; // 阻止默认 form 跳转
});
});
</script>

</body>
</html>
import com.google.gson.Gson;
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;
import java.util.ArrayList;
import java.util.List;

@WebServlet("/getdata")
public class getdata extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse resp) throws ServletException, IOException {
Dao dao=new Dao();
String name=request.getParameter("name");
System.out.println(name+"name");
List<User> list = new ArrayList<>();
List<User> list1 = new ArrayList<>();
try {
list = dao.get(name);
}catch (Exception e){
e.printStackTrace();
}
//list=dao.getlimit(name,document,number,text,page,limit);
//list1=dao.get2(name);
Vo vo = new Vo();
vo.setCode(0);
vo.setMsg("success");
vo.setCount(dao.getcount(name));
vo.setData(list);
Gson gson = new Gson();
String a = gson.toJson(vo);
resp.getWriter().write(a);
}
}
posted @ 2024-12-02 23:03  欧吼吼  阅读(2)  评论(0编辑  收藏  举报