学生管理系统VueAjax版本

学生管理系统VueAjax版本

使用Vue和Ajax对原有学生管理系统进行优化

1.准备工作

创建AjaxResult类,对Ajax回传的信息封装在对象中

package com.grg.Result;/*** @Author Grg* @Date 2023/8/30 8:51* @PackageName:com.grg.Result* @ClassName: AjaxResult* @Description: 又是码代码的一天* @Version plus max 宇宙无敌终极版本*/
public class AjaxResult {private Integer code;private String msg;private Object data;public static AjaxResult success() {return new AjaxResult(1, "成功", null);}public static AjaxResult success(Object data) {return new AjaxResult(1, "成功", data);}public static AjaxResult error() {return new AjaxResult(2, "失败", null);}public AjaxResult() {}public AjaxResult(Integer code, String msg, Object data) {this.code = code;this.msg = msg;this.data = data;}@Overridepublic String toString() {return "AjaxResult{" +"code=" + code +", msg='" + msg + '\'' +", data=" + data +'}';}public Integer getCode() {return code;}public void setCode(Integer code) {this.code = code;}public String getMsg() {return msg;}public void setMsg(String msg) {this.msg = msg;}public Object getData() {return data;}public void setData(Object data) {this.data = data;}
}

JDBC工具类DAOUtil

package com.grg.util;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;/*** @Author Grg* @Date 2023/8/26 14:35* @PackageName:com.grg.util* @ClassName: DAOUtil* @Description: 又是码代码的一天* @Version plus max 宇宙无敌终极版本*/
public class DAOUtil {//消除魔法值private static final String CLASSNAME = "com.mysql.cj.jdbc.Driver";private static final String URL = "jdbc:mysql:///jdbctest";private static final String USERNAME = "root";private static final String PASSWORDS = "123456";//加载驱动static {try {Class.forName(CLASSNAME);} catch (ClassNotFoundException e) {throw new RuntimeException(e);}}//建立连接public static Connection getConnection() throws Exception {return DriverManager.getConnection(URL, USERNAME, PASSWORDS);}//增删改public static int executeUpdate(String sql, Object... data) {Connection conn = null;try {conn = DAOUtil.getConnection();PreparedStatement ps = conn.prepareStatement(sql);for (int i = 0; i < data.length; i++) {ps.setObject(i + 1, data[i]);}return ps.executeUpdate();} catch (Exception e) {e.printStackTrace();} finally {try {if (conn != null) {conn.close();}} catch (Exception e) {e.printStackTrace();}}return 0;}//查public static List<Map<String, Object>> executeQuery(String sql, Object... arr) {List<Map<String, Object>> data = new ArrayList<>();Connection conn = null;try {conn = DAOUtil.getConnection();PreparedStatement ps = conn.prepareStatement(sql);for (int i = 0; i < arr.length; i++) {ps.setObject(i + 1, arr[i]);}ResultSet set = ps.executeQuery();int columnCount = set.getMetaData().getColumnCount();while (set.next()) {HashMap<String, Object> map = new HashMap<>();for (int i = 0; i < columnCount; i++) {map.put(set.getMetaData().getColumnLabel(i + 1), set.getObject(i + 1));}data.add(map);}} catch (Exception e) {e.printStackTrace();} finally {try {if (conn != null) {conn.close();}} catch (Exception e) {e.printStackTrace();}}return data;}
}

pom文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>StudentVue</artifactId><packaging>war</packaging><version>1.0-SNAPSHOT</version><name>StudentVue Maven Webapp</name><url>http://maven.apache.org</url><dependencies><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.33</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>4.0.1</version></dependency><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency><dependency><groupId>taglibs</groupId><artifactId>standard</artifactId><version>1.1.2</version></dependency><dependency><groupId>com.alibaba</groupId><artifactId>fastjson</artifactId><version>2.0.2</version></dependency></dependencies><build><finalName>StudentVue</finalName></build>
</project>

2.登录模块

登录页面(默认页面)index.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><!-- 最新版本的 Bootstrap 核心 CSS 文件 --><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css"integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"><script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script><script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script><style>fieldset {margin: 100px auto;width: 500px;}</style></head>
<body>
<div id="app"><fieldset><legend>登录</legend><span class="label label-danger">{{msg}}</span><div class="form-group"><label>UserName</label><input class="form-control" placeholder="请输入账号" v-model="info.username"></div><div class="form-group"><label>Password</label><input type="password" class="form-control" placeholder="请输入密码" v-model="info.password"></div><button type="submit" class="btn btn-danger btn-block" @click="login()">登录</button></fieldset>
</div><script>var haha = new Vue({el: "#app",data: {info: {},msg: "",},methods: {login: function () {//数据校验//发送请求$.post("/day/emp/login", haha.info, function (backData) {if (backData.code == 1) {//跳转主界面window.location.href = "/day/main.html"} else {//显示失败信息haha.msg = "对不起账号或密码错误"}})}}})
</script>
</body>
</html>

对/day/emp/login发送post请求,查询数据并且回传

EmpServlet类 拦截到/emp/*的请求并进行处理

创建dao层 EmpDAO类和EmpDAOImpl实现类 实现对数据库中数据进行账号密码验证

EmpDAO接口

public interface EmpDAO {List<Map<String,Object>> login(String username, String password);
}

EmpDAO实现类

public class EmpDAOImpl implements EmpDAO {@Overridepublic List<Map<String, Object>> login(String username, String password) {String sql = "select * from login where username = ? and password = ? ";return DAOUtil.executeQuery(sql, username, password);}
}

EmpServlet类

package com.grg.servlet;import com.alibaba.fastjson.JSON;
import com.grg.Result.AjaxResult;
import com.grg.dao.EmpDAO;
import com.grg.dao.impl.EmpDAOImpl;import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;/*** @Author Grg* @Date 2023/8/30 8:49* @PackageName:com.grg.servlet* @ClassName: EmpServlet* @Description: 又是码代码的一天* @Version plus max 宇宙无敌终极版本*/
@WebServlet("/emp/*")
public class EmpServlet extends HttpServlet {private EmpDAO empDAO = new EmpDAOImpl();@Overrideprotected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {//路径分发String uri = req.getRequestURI();String[] arr = uri.split("/");String s = arr[arr.length - 1];resp.setContentType("text/json;charset=UTF-8");PrintWriter out = resp.getWriter();AjaxResult ajaxResult = null;if ("login".equals(s)) {ajaxResult = login(req, resp);}String s1 = JSON.toJSONString(ajaxResult);out.write(s1);}protected AjaxResult login(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {//1.接收请求参数String username = req.getParameter("username");String password = req.getParameter("password");//2.校验账号密码List<Map<String, Object>> data = empDAO.login(username, password);if (data.size() > 0) {return AjaxResult.success();}return AjaxResult.error();}
}

当账号密码错误时,响应 {“code”:2,“msg”:“失败”}

当账号密码正确时,进入main.html

<!DOCTYPE html>
<html lang="zh-CN">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>信息管理系统</title><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css"integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"><script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script><script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script><style>body {background: url('./img/reg_bg_min.jpg') no-repeat;background-size: 100% 100%;}a {text-decoration: none;color: white;}body {font-family: Arial, sans-serif;margin: 0;padding: 0;}#header {background-color: #000000;/*color: #ffffff;*/padding: 10px;display: flex;justify-content: space-between;}#header h1, #header p {margin: 0;}#sidebar {/*background-color: #e1e1e1;*/width: 200px;height: 100vh;float: left;}#content {padding: 20px;margin-left: 200px;}#footer {/*background-color: #f5f5f5;*/padding: 10px;clear: both;}.menu-item {padding: 10px;margin-top: 10px;}.menu-item:hover {background-color: #d1d1d1;}#iframe-container {width: calc(100% - 20px);height: calc(100vh - 20px);}#iframe-content {width: 100%;height: 100%;border: none;}</style>
</head>
<body>
<div id="header"><!-- 学生管理系统的Logo和标题 --><h1 style="color:white;">信息管理系统</h1><!-- 用户信息和注销按钮 --><p style="color:white;">当前登录用户:</p></div>
<div id="sidebar"><!-- 左侧菜单 --><div class="menu-item"><a target="haha" href="/day/views/student/list.html">学生管理</a></div><div class="menu-item"><a target="haha" href="/teacher/show">教师管理</a></div><div class="menu-item"><a target="haha" href="/class/show">班级管理</a></div><div class="menu-item"><a target="haha" href="/views/emp/changepassword.jsp">修改密码</a></div><div class="menu-item"><a target="haha" href="/log">日志记录</a></div><div class="menu-item"><a href="/">注销</a></div>
</div>
<div id="content"><div id="iframe-container"><iframe name="haha" src="" id="iframe-content"></iframe></div></div>
<div id="footer"><!--     页面底部区域,可根据需求添加内容 --><p style="color:white;">版权所有 &copy; 2023 学生管理系统</p>
</div>
</body>
</html>

3.学生管理

3.1查询学生

点击学生管理获取学生数据并且展示在页面上

<a target="haha" href="/day/views/student/list.html">学生管理</a>

创建list.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><!-- 最新版本的 Bootstrap 核心 CSS 文件 --><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css"integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"><script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script><script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<body>
<div id="app"><a href="/day/views/student/add.html" class="btn btn-success">添加学生</a><table class="table table-bordered table-condensed table-striped"><tr><th>编号</th><th>姓名</th></tr><tr v-for="(s,i) in stuArr"><td>{{s.id}}</td><td>{{s.name}}</td><td><button class="btn btn-danger" @click="delStu(s.id)">删除</button><button class="btn btn-primary">修改</button></td></tr></table>
</div><script>$.get("/day/stu/list", function (backData) {haha.stuArr = backData.data;})var haha = new Vue({el: "#app",data: {stuArr: []},methods: {delStu: function (a) {if (confirm("确定删除?")) {$.get("/day10/stu/delete?id=" + a, function (backDate) {if (backDate.code == 2) {alert("删除失败")} else {window.location.reload();}})}}}});
</script>
</body>
</html>

进入页面后通过ajax获取学生数据,并把返回的数据存入haha.stuArr数组中

$.get("/day/stu/list", function (backData) {haha.stuArr = backData.data;})

/day/stu/list执行list函数

创建StudentServlet类、StudentDAO接口、StudentDAOImpl实现类

StudentDAO接口

public interface StudentDAO {public List<Map<String, Object>> listAllStudent();public int deleteStudentById(String id);
}

StudentDAOImpl实现类

public class StudentDAOImpl implements StudentDAO {@Overridepublic List<Map<String, Object>> listAllStudent() {String sql = "select s.id,s.name from student s";return DAOUtil.executeQuery(sql);}@Overridepublic int deleteStudentById(String id) {String sql = "delete from student where id = ? ";return DAOUtil.executeUpdate(sql, id);}
}

StudentServlet类

package com.grg.servlet;import com.alibaba.fastjson.JSON;
import com.grg.Result.AjaxResult;
import com.grg.dao.StudentDAO;
import com.grg.dao.impl.StudentDAOImpl;import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;/*** @Author Grg* @Date 2023/8/30 8:49* @PackageName:com.grg.servlet* @ClassName: StudentServlet* @Description: 又是码代码的一天* @Version plus max 宇宙无敌终极版本*/
@WebServlet("/stu/*")
public class StudentServlet extends HttpServlet {private StudentDAO studentDAO = new StudentDAOImpl();@Overrideprotected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String uri = req.getRequestURI();String[] arr = uri.split("/");String s = arr[arr.length - 1];resp.setContentType("text/json;charset=UTF-8");PrintWriter out = resp.getWriter();AjaxResult ajaxResult = null;if ("list".equals(s)) {ajaxResult = list(req, resp);} else if ("delete".equals(s)) {ajaxResult = delete(req, resp);}String s1 = JSON.toJSONString(ajaxResult);out.write(s1);}protected AjaxResult list(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {List<Map<String, Object>> list = studentDAO.listAllStudent();return AjaxResult.success(list);}protected AjaxResult delete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String id = req.getParameter("id");int i = studentDAO.deleteStudentById(id);if (i > 0) {return AjaxResult.success();}return AjaxResult.error();}
}

3.2删除学生

点击删除按钮 执行点击事件函数delStu

在StudentServlet中执行删除

<button class="btn btn-danger" @click="delStu(s.id)">删除</button>
 methods: {delStu: function (a) {if (confirm("确定删除?")) {$.get("/day/stu/delete?id=" + a, function (backDate) {if (backDate.code == 2) {alert("删除失败")} else {window.location.reload();}})}}}

3.3添加学生

<a href="/day/views/student/add.html" class="btn btn-success">添加学生</a>

add.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><!-- 最新版本的 Bootstrap 核心 CSS 文件 --><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css"integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"><script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script><script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<style>fieldset {width: 500px;margin: 100px auto;}
</style>
<body><div id="app"><fieldset><legend>添加学生<span class="label label-primary"></span></legend><div class="form-group"><label for="inputEmail3" class="col-sm-2 control-label">学生姓名</label><div class="col-sm-10"><input name="name" v-model="stuInfo.name" type="text" class="form-control" id="inputEmail3"placeholder="请输入学生姓名"></div></div><div class="form-group"><label for="inputPassword3" class="col-sm-2 control-label">学生年龄</label><div class="col-sm-10"><input name="age" v-model="stuInfo.age" type="text" class="form-control" id="inputPassword3"placeholder="请输入学生年龄"></div></div><div class="form-group"><label class="col-sm-2 control-label">学生住址</label><div class="col-sm-10"><select name="address" v-model="stuInfo.address"><option>北京</option><option>郑州</option><option>上海</option></select></div></div><div class="form-group"><label class="col-sm-2 control-label">学生班级</label><div class="col-sm-10"><select name="address" v-model="stuInfo.gid"><option value="1">一年级</option><option value="2">二年级</option><option value="3">三年级</option></select></div></div><div class="form-group"><div class="col-sm-offset-2 col-sm-10"><button type="submit" class="btn btn-default btn-success" @click="add()">添加</button></div></div></fieldset>
</div><script>var haha = new Vue({el: "#app",data: {stuInfo: {},},methods: {add: function () {$.post("/day/stu/addStu", haha.stuInfo, function (backData) {})}}})
</script>
</body>
</html>

执行添加操作,在StudentServlet中执行addStu函数,并且编写DAO层相应添加函数

$.post("/day/stu/add", haha.stuInfo, function (backData) {
@Overridepublic int addStu(Student student) {String sql = "insert into student values (null,?,?,?,?)";return DAOUtil.executeUpdate(sql,student.getName(),student.getAge(),student.getAddress(),student.getGid());}
protected AjaxResult addStu(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String name = req.getParameter("name");String age = req.getParameter("age");String address = req.getParameter("address");String gid = req.getParameter("gid");Student student = new Student(name, age,address,Integer.parseInt(gid));int i = studentDAO.addStu(student);if (i > 0) {return AjaxResult.success();}return AjaxResult.error();}

3.4修改学生

点击修改按钮执行点击事件updateStu函数

<button class="btn btn-primary" @click="updateStu(s.id)">修改</button>
updateStu: function (a) {window.location.href = "/day/views/student/update.html?id=" + a;}

update.html

<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><title>Title</title><!-- 最新版本的 Bootstrap 核心 CSS 文件 --><link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css"integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"><script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script><script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
</head>
<style>fieldset {width: 500px;margin: 100px auto;}.col-sm-10 {width: 85.333333%;}.btn-block {width: 63%;}
</style>
<body>
<div id="app"><fieldset><legend>修改学生<span class="label label-primary">{{msg}}</span></legend><div><label class="col-sm-2 control-label">姓名</label><div class="col-sm-10"><input type="text" class="form-control" v-model="stuInfo.name"></div></div><div><label class="col-sm-2 control-label">年龄</label><div class="col-sm-10"><input type="text" class="form-control" v-model="stuInfo.age"></div></div><div><label class="col-sm-2 control-label">住址</label><div class="col-sm-10"><select name="address" v-model="stuInfo.address"><option>北京</option><option>郑州</option><option>上海</option></select></div></div><div><label class="col-sm-2 control-label">班级</label><div class="col-sm-10"><select name="gid" v-model="stuInfo.gid"><option value="1">一年级</option><option value="2">二年级</option><option value="3">三年级</option></select></div></div><div><div class="col-sm-offset-2 col-sm-10"><button type="submit" class="btn btn-info btn-block" @click="update()">修改</button><a href="/day/views/student/list.html" class="btn btn-info btn-block">返回</a></div></div></fieldset>
</div><script>var id = window.location.href.split("=")[1];$.get("/day/stu/getStu?id=" + id, function (backData) {haha.stuInfo = backData.data;})var haha = new Vue({el: "#app",data: {stuInfo: {},msg:""},methods: {update: function () {$.post("/day/stu/updateStu",haha.stuInfo,function (backData) {haha.msg = backData.msg;})}}})
</script>
</body>
</html>

先发送请求到getStu

protected AjaxResult getStu(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String id = req.getParameter("id");List<Map<String, Object>> data = studentDAO.getStudentById(id);if (data.size() > 0) {return AjaxResult.success(data.get(0));} else {return AjaxResult.error();}}

点击修改按钮发送请求到updateStu

protected AjaxResult updateStu(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String name = req.getParameter("name");String age = req.getParameter("age");String address = req.getParameter("address");String gid = req.getParameter("gid");String id = req.getParameter("id");Student student = new Student(Integer.parseInt(id), name, age, address, Integer.parseInt(gid));int i = studentDAO.updateStu(student);if (i > 0) {return AjaxResult.success();}return AjaxResult.error();}

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/118126.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

stm32f1xx单片机拦截中断源代码

这个是实现后的效果&#xff0c;可以看到已经没有中断的效果了 这个是拦截前的效果可以看到电平是在变化的 实现原理非常简单&#xff1a;一句话搞定&#xff1a; if(TIM2->CNTTIM2->ARR-5)TIM2->CNT-5; 以下是完整的代码&#xff1a;是用来补充说明和筹字数的 /* …

CSS 一个好玩的卡片“开卡效果”

文章目录 一、用到的一些CSS技术二、实现效果三、代码 一、用到的一些CSS技术 渐变 conic-gradientbox-shadowclip-path变换、过渡 transform、transition动画 animation keyframes伪类、伪元素 :hover、::before、::after …绝对布局。。。 clip-path 生成网站 https://techb…

二进制转换16进制 快速心算

1111 1110 ---> 0xFE 1111 为 8 4 2 1 ---> 8 4 2 1 15 --> 16进制表示为F1110 为 8 4 2 0 ---> 8 4 2 0 14 --> 16进制表示为E

Vulnstack----5、ATTCK红队评估实战靶场五

文章目录 一 环境搭建二 外网渗透三 内网信息收集3.1 本机信息收集3.2 域内信息收集 四 横向移动4.1 路由转发和代理通道4.2 抓取域用户密码4.3 使用Psexec登录域控4.4 3389远程登录 五、痕迹清理 一 环境搭建 1、项目地址 http://vulnstack.qiyuanxuetang.net/vuln/detail/7/ …

合宙Air724UG LuatOS-Air LVGL API控件--进度条 (Bar)

进度条 (Bar) Bar 是进度条&#xff0c;可以用来显示数值&#xff0c;加载进度。 示例代码 – 创建进度条 bar lvgl.bar_create(lvgl.scr_act(), nil) – 设置尺寸 lvgl.obj_set_size(bar, 200, 20); – 设置位置居中 lvgl.obj_align(bar, NULL, lvgl.ALIGN_CENTER, 0, 0) …

js实现点击查看全部/收起功能

在上一篇文章实现用js截取文本后&#xff0c;我的另一个需求也迎刃而解了。需求就是一段长文本需要溢出隐藏&#xff0c;然后点击全部时显示全部文本&#xff0c;点击收起又回到溢出隐藏的状态。实现的效果如下图&#xff1a; 实现的思路时点击全部时使用这条数据的原文本&…

设计模式-中介者模式

文章目录 一、前言二、中介者模式1、定义2、未使用/使用中介者模式对比2.1、未使用中介者模式&#xff1a;2.2、使用中介者模式&#xff1a; 3、角色分析3.1、中介者&#xff08;Mediator&#xff09;&#xff1a;3.2、同事&#xff08;Colleague&#xff09;&#xff1a;3.3、…

tableau基础学习2:时间序列数据预处理与绘图

文章目录 数据预处理1. 原始数据2. 合并数据集2. 创建计算字段 绘图分析1. 趋势分析2. 计算字段趋势分析 这一部分&#xff0c;我们记录一些分析时序趋势的分析步骤 数据预处理 1. 原始数据 原始数据是excel表格&#xff0c;其中包含三个Sheet页&#xff0c; 这里我们选择两…

02-请解释一下Java的内存模型和happens-before规则?【Java面试题总结】

请解释一下Java的内存模型和happens-before规则&#xff1f; 概念&#xff1a;Java内存模型&#xff0c;简称JMM&#xff0c;是一种定义了多线程程序中内存访问行为的规范。它定义了线程如何与主内存和工作内存进行交互&#xff0c;以及如何保证多线程程序的正确性和可见性。J…

ChatGPT Prompting开发实战(三)

一、关于chaining prompts与CoT的比较 前面谈到的CoT的推理过程&#xff0c;可以比作是一次性就烹调好一顿大餐&#xff0c;那么接下来要说的“chaining prompts”&#xff0c;其背后的理念是分多次来完成这样一项复杂任务&#xff0c;每次只完成其中一步或者一个子任务。核心…

探索图像数据中的隐藏信息:语义实体识别和关系抽取的奇妙之旅

探索图像数据中的隐藏信息&#xff1a;语义实体识别和关系抽取的奇妙之旅 1. 简介 1.1 背景 关键信息抽取 (Key Information Extraction, KIE)指的是是从文本或者图像中&#xff0c;抽取出关键的信息。针对文档图像的关键信息抽取任务作为OCR的下游任务&#xff0c;存在非常…

2023年的深度学习入门指南(26) - 在自己电脑上运行通义千问7b模型

2023年的深度学习入门指南(26) - 在自己电脑上运行通义千问7b模型 通过量化&#xff0c;通义千问4位量化的模型大小为5.86G&#xff0c;可以在3060等小于16G的家用GPU上也可以运行起来。 通义千问7b的量化运行 通义千问7b提供了4位量化好的Qwen/Qwen-7B-Chat-Int4模型&#…

无涯教程-Android - RadioGroup函数

RadioGroup类用于单选按钮集。 如果我们选中属于某个单选按钮组的一个单选按钮,它将自动取消选中同一组中以前选中的任何单选按钮。 RadioGroup属性 以下是与RadioGroup控制相关的重要属性。您可以查看Android官方文档以获取属性的完整列表以及可以在运行时更改这些属性的相关…

day-07 I/O复用(select)

一.I/O复用 &#xff08;一&#xff09;基于I/O复用的服务器端 1.多进程服务器 每次服务都需要创建一个进程&#xff0c;需要大量的运算和内存空间 2.复用 只需创建一个进程。 3.复用技术在服务器端的应用 &#xff08;二&#xff09;select函数实现服务器端 &#xff08;…

03-基础例程3

基础例程3 01、外部中断 ESP32的外部中断有上升沿、下降沿、低电平、高电平触发模式。 实验目的 使用外部中断功能实现按键控制LED的亮灭 按键按下为0。【即下降沿】 * 接线说明&#xff1a;按键模块-->ESP32 IO* (K1-K4)-->(14,27,26,25)* * …

软件测试Day6|接口测试

学习流程 接口测试流程 需求分析和评审–接口文档分析–编写测试用例–测试用例设计及评审–测试脚本构建–执行测试用例–缺陷管理和回归–测试报告和总结计网基础&#xff08;URL、请求、响应&#xff09; 接口文档解析 拿到一个项目接口之后&#xff0c;先测试业务接口还是…

抽象轻松的C语言

#include <stdio.h> /* 预处理指令*/ /* 函数 */ int main() {int log 3.14;printf("hello word * %d\n easy", log);getchar();/* 获取键盘输入的字母&#xff0c;在这个程序中的作用是防止程序瞬间关闭 */return 0; } 上一篇说过&#xff0c;C程序是C语言的…

21.4 CSS 盒子模型

1. 边框样式 border-style属性: 指定元素的边框样式.常用属性值: - none: 无边框(默认值). - solid: 实线边框. - dotted: 点状边框. - dashed: 虚线边框. - double: 双线边框. - groove: 凹槽状边框. - ridge: 脊状边框. - inset: 内阴影边框. - outset: 外阴影边框.这些值可…

「MySQL-02」数据库的操纵、备份、还原和编码规则

目录 一、库操作 1. 创建数据库 2. 查看所有数据库 3. 删除数据库 4. 修改数据库 5. 进入一个数据库 二、查看和设置数据库的编码规则 1. MySQL的两个编码规则&#xff1a;字符集和校验规则 2. 查看MySQL当前使用的字符集以及校验规则 3. 查看MySQL支持的所有字符集 4. 查看MyS…