当前位置: 首页 > news >正文

JSP+Servlet+Mybatis实现列表显示和批量删除等功能

前言

  • 使用JSP回显用户列表,可以进行批量删除(有删除确认步骤),和修改用户数据(用户数据回显步骤)
  • 使用servlet处理传递进来的请求参数,并调用dao处理数据并返回
  • 使用mybatis,书写dao层,获取mysql数据库数据并返回到servlet

项目实现步骤

完整项结构

第一步:创建项目,配置pom.xml文件,导入相关工具类

pom.xml

 <dependencies><!--单元测试--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version><scope>test</scope></dependency><!--mysql数据库连接--><dependency><groupId>mysql</groupId><artifactId>mysql-connector-java</artifactId><version>8.0.21</version></dependency><!--servlet--><dependency><groupId>javax.servlet</groupId><artifactId>javax.servlet-api</artifactId><version>3.1.0</version><scope>provided</scope></dependency><!--lombok--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>1.18.24</version><scope>provided</scope></dependency><!---mybatis--><dependency><groupId>org.mybatis</groupId><artifactId>mybatis</artifactId><version>3.4.6</version></dependency><!--log4j--><dependency><groupId>log4j</groupId><artifactId>log4j</artifactId><version>1.2.17</version></dependency><!--jstl--><dependency><groupId>javax.servlet</groupId><artifactId>jstl</artifactId><version>1.2</version></dependency></dependencies><build><finalName>project1</finalName><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.1</version><configuration><source>1.8</source><target>1.8</target><encoding>UTF-8</encoding></configuration></plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-war-plugin</artifactId><version>3.3.2</version></plugin><plugin><groupId>org.eclipse.jetty</groupId><artifactId>jetty-maven-plugin</artifactId><version>9.3.14.v20161028</version></plugin><plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.1</version><configuration><port>8080</port><path>/my_maven_pro</path><uriEncoding>UTF-8</uriEncoding><server>tomcat7</server></configuration></plugin></plugins></build>
</project>
  • 因为要使用mybatis,因此需要导入创建SqlSession的工具类,目的是创建sqlsession对象来发送sql,获取数据;
  • 因为需要使用log4j日志,需要导入其配置文件相关设置;
  • 因为mybatis配置了jdbc连接信息和mybatis配置信息分离,所以要jdbc.properties文件

SqlSessionFactoryUtil 

public class SqlSessionFactoryUtil {private static SqlSessionFactory factory;private SqlSessionFactoryUtil(){}static {Reader reader=null;try {reader=reader= Resources.getResourceAsReader("mybatis.xml");factory=new SqlSessionFactoryBuilder().build(reader);} catch (IOException e) {throw new RuntimeException(e);}}public static SqlSession getSessionSql(){return factory.openSession(true);}}

openSession()方法参数为true,表示自动提交事务。

jdbc.properties

driver=com.mysql.cj.jdbc.Driver
url=jdbc:mysql://localhost:3306/csx_demo_925?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull
username=root
password=root

jdbc的连接信息需要自己本地的mysql连接配置

log4j.properties

### set log levels ###
log4j.rootLogger = debug,stdout 
log4j.appender.stdout = org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target = System.out
log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern =  %d %p [%c] - %m%nlog4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=debug
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=debug
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=debug
log4j.logger.java.sql.Connection=debug
log4j.logger.java.sql.Statement=debug
log4j.logger.java.sql.PreparedStatement=debug,stdout

配置mybatis日志文件,在执行mybatis相关的sql时,可以看到sql语句的执行流程

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaeehttp://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"version="3.0"><display-name>Archetype Created Web Application</display-name></web-app>

web.xml配置的头信息,需要指定3.0版本以上,目的是可以在servlet中使用注解完成相关的映射配置

第二步:创建数据库表和对应实体类

数据库表

t_user用户表,包含字段为user_id(用户id),user_name(用户名),user_pic(用户头像),user_point(用户积分);这里用户头像暂时用不到

 建表语句
create table if not exists t_user(
user_id int primary key auto_increment comment '用户id,主键',
user_name varchar(30) not null unique comment'用户名',
password varchar(30) not null comment'密码',
user_pic varchar(50) comment'用户头像',
user_point int default 0  comment'用户积分'
);

User

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class User implements Serializable {private Integer userId;private String userName;private String password;private String userPic;private Integer userPoint;
}

属性名和字段名采用了小驼峰映射,需要在mybatis中手动配置类的属性和表中字段的映射关系。

 第三步:创建Mybatis主配置文件,Dao层和mapper映射

mybatis.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN""http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration><properties resource="jdbc.properties"/><!--<settings><setting name="" value=""/></settings>--><typeAliases><package name="com.csx.entity"/></typeAliases><environments default="development"><environment id="development"><transactionManager type="JDBC"/><dataSource type="POOLED"><property name="driver"value="${driver}"/><property name="url"value="${url}"/><property name="username" value="${username}"/><property name="password" value="${password}"/></dataSource></environment></environments><mappers><mapper resource="mapper/UserMapper.xml"></mapper></mappers></configuration>

注意:

  • <properties resource="jdbc.properties"/>:配置了jdbc连接信息的路径,可以在mybatis.xml中使用${}引入jdbc.properties的配置信息
  • <typeAliases><package name="com.csx.entity"/>
    </typeAliases>
    • 设置别名,将entity包下的所有实体类,都设置别名,为类名或类名的全小写
  • mappers标签中的mapper标签,需要先存在mappper映射文件才能配置其和主配置文件的绑定。

UserDao

public interface UserDao {//查询所有用户List<User> getUserList();//根据id查询指定用户User getUserById(int id);//更新用户int updateUser(User user);//删除单个用户    int delUser(int id);//批量删除用户int delUsers(int[] ids);}

项目需要的所有sql支持,从上到下分别为:查询所有用户数据;根据id查询指定用户;修改用户数据;删除用户数据(删除单个);批量删除用户数据

UserMapper.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN""http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.csx.dao.UserDao"><resultMap id="userCols" type="user"><id property="userId" column="user_id"/><result property="userName" column="user_name"/><result property="userPic" column="user_pic"/><result property="userPoint" column="user_point"/></resultMap><!--查询所有用户--><select id="getUserList" resultMap="userCols">select * from t_user</select>
<!--根据id查询指定用户--><select id="getUserById" parameterType="int" resultMap="userCols">select * from t_userwhere user_id = #{id}</select>
<!--根据id修改用户名和积分--><update id="updateUser" parameterType="user">update t_user set user_name = #{userName},user_point=#{userPoint}where user_id = #{userId}</update>
<!--删除单个用户数据--><delete  id="delUser" parameterType="int">delete from t_user where user_id = #{id}</delete>
<!--批量删除用户数据,接收参数类型为数组--><delete id="delUsers">delete from t_user where user_id in<foreach collection="array" item="id" open="(" close=")" separator=",">#{id}</foreach></delete></mapper>
书写mapper.xml时需要注意使用 <resultMap>配置数据库字段和实体类的属性一一映射

第四步:创建service层

UserService

public interface UserService {List<User> getUserList();User getUserById(int id);int updateUser(User user);int delUser(int id);int delUsers(String[] ids);}

UserServiceImpl

public class UserServiceImpl implements UserService {SqlSession session= SqlSessionFactoryUtil.getSessionSql();UserDao userDao=session.getMapper(UserDao.class);@Overridepublic List<User> getUserList() {return userDao.getUserList();}@Overridepublic User getUserById(int id) {return userDao.getUserById(id);}@Overridepublic int updateUser(User user) {return userDao.updateUser(user);}@Overridepublic int delUser(int id) {return userDao.delUser(id);}@Overridepublic int delUsers(String[] ids) {//将字符串数组转换成int数组,需要判断null值if (ids!=null){int[] idss= Arrays.stream(ids).mapToInt(Integer::parseInt).toArray();return userDao.delUsers(idss);}return 0;}
}

 service层,作用是调用dao的sql支持,完成业务逻辑,就像上面的类型转换的操作,实在service层实现的

第五步:创建前端页面和servlet

前端页面:执行逻辑--->当我们启动服务器时,在浏览器输入localhost:8080  默认访问的是index.html或index.jsp页面,因此我们可以直接在index.html页面完成跳转功能,跳转到我们的servlet进行逻辑处理(获取数据库中的数据,然后在页面展示)

 index.html

<html>
<body>
<h2>Hello World!</h2>
</body>
<script>location.href="toIndex";
</script>
</html>

在默认首页完成跳转到指定的servlet进行逻辑处理

ToIndexServlet

@WebServlet("/toIndex")
public class ToIndexServlet extends HttpServlet {@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {UserService userService=new UserServiceImpl();//调用mybatis方法,获取所有用户数据List<User> list= userService.getUserList();//将存有用户数据的list集合放在request中req.setAttribute("list",list);//转发请求到list.jsp页面req.getRequestDispatcher("list.jsp").forward(req,resp);}@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req, resp);}
}

servlet的作用是获取所有用户信息,存放在list集合中,在存放到request作用域进行转发请求操作到list.jsp页面

 list.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML>
<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head><meta charset="UTF-8"><meta name="description" content=""><meta name="keywords" content=""><title></title>
</head>
<body><table border="1px"><tr><th></th><th>编号</th><th>姓名</th><th>积分</th><th>积分</th></tr><form action="subSelItem" method="post"><c:forEach items="${list}" var="u"><tr><td><input type="checkbox" name="selItems" value="${u.userId}"></td><td>${u.userId}</td><td>${u.userName}</td><td>${u.userPoint}</td><td><a href="toUserDetail?userId=${u.userId}">修改</a><a href="delUser?userId=${u.userId}" onclick="return delUser()">删除</a></td></tr></c:forEach><input type="submit" value="删除所选" onclick="return delUser()"></form></table>
</body>
<script>function delUser(){var ans= confirm("忍心删除吗?");if(ans){return true;}else{return false;}}
</script></html>  
  • 使用jstl标签库中的forEach标签,结合el表达式获取数据,遍历存放在request作用域中的list集合结合中的数据
  • 通过两个超链接<a>,进行页面跳转和数据传递,处理修改和删除业务
  • 通过表单包裹checkbox复选框,实现批量删除的请求;

注意:这里只展示了用户的id,用户名和用户积分

 修改功能实现

修改逻辑的执行流程:

  1. 点击修改按钮,跳转到处理修改的/toUserDetail的servlet类,作用是获取当前用户信息,回显数据
  2. 由/toUserDetail的servlet跳转到修改页面userDetail.jsp,进行修改操作
  3. 将修改后的数据提交到另一个/updateUser的servlet中进行数据库更新操作
  4. 更新完成后,跳转到/toIndex的servlet获取数据库用户列表
  5. 获取完数据库用户数据后,跳转到list.jsp展示

ToUserDetailServlet

@WebServlet("/toUserDetail")
public class ToUserDetailServlet extends HttpServlet {@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {int id=Integer.parseInt(req.getParameter("userId"));UserService userService=new UserServiceImpl();User user= userService.getUserById(id);req.setAttribute("user",user);req.getRequestDispatcher("userDetail.jsp").forward(req,resp);}@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req, resp);}
}

根据请求参数的用户id获取用户对象,将用户对象存放在request作用域,并转发请求到userDetail.jsp

 userDetail.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML>
<html>
<meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head><meta charset="UTF-8"><meta name="description" content=""><meta name="keywords" content=""><title>页面修改</title>
</head>
<body><form action="updateUser" method="post"><input type="hidden" name="userId" value="${user.userId}">姓名: <input type="text" name="userName" value="${user.userName}"> <br/>积分: <input type="text" name="userPoint" value="${user.userPoint}"> <br/><input type="submit" value="确认修改"></form></body>
</html>  

进行页面回显操作,点击提交按钮,将数据提交到/updateUser的servlet类处理

UpdateUserServlet
@WebServlet("/updateUser")
public class UpdateUserServlet extends HttpServlet {@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {int id= Integer.parseInt(req.getParameter("userId"));String user_name= req.getParameter("userName");int score= Integer.parseInt(req.getParameter("userPoint"));User user=new User();user.setUserId(id);user.setUserName(user_name);user.setUserPoint(score);UserService userService=new UserServiceImpl();userService.updateUser(user);resp.sendRedirect("toIndex");}@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req, resp);}
}

将提交数据更新到数据库中,然后回到/toIndex的servlet类中,重新获取数据库中的用户列表,然后跳转到list.jsp展示查看

 删除单个功能

步骤:

  1. 在list.jsp中点击删除按钮,出现提示框,点击确认,跳转到delUser的servlet类中处理
  2. 在delUser的servlet类中进行删除操作,删除完毕后跳转到toIndex的servlet类中,重新获取数据库中的用户列表
  3. 跳转到list.jsp展示

DelUserServlet

@WebServlet("/delUser")
public class DelUserServlet extends HttpServlet {@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {int id= Integer.parseInt(req.getParameter("userId"));UserService userService=new UserServiceImpl();userService.delUser(id);resp.sendRedirect("toIndex");}@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req, resp);}
}

 批量删除功能

在list.jsp中使用表单包裹checkbox复选框,当选中多个提交时,在对应的servlet中使用

getParameterValues()方法接收到字符串数组,将字符串数组转换成int数组,底层通过mybatis的forEach标签进行批量删除

SubSelItemServlet

@WebServlet("/subSelItem")
public class SubSelItemServlet extends HttpServlet {@Overrideprotected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {String[] items= req.getParameterValues("selItems");UserService userService=new UserServiceImpl();userService.delUsers(items);resp.sendRedirect("toIndex");}@Overrideprotected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {doPost(req, resp);}
}

业务处理:字符串数组转int数组

mybatis的sql处理:

总结

基于jsp+servlet+mybatis实现用户列表查看,用户修改,删除单个用户(确认步骤),批量删除用户等功能实现

相关文章:

JSP+Servlet+Mybatis实现列表显示和批量删除等功能

前言 使用JSP回显用户列表&#xff0c;可以进行批量删除&#xff08;有删除确认步骤&#xff09;&#xff0c;和修改用户数据&#xff08;用户数据回显步骤&#xff09;使用servlet处理传递进来的请求参数&#xff0c;并调用dao处理数据并返回使用mybatis&#xff0c;书写dao层…...

Cannot read properties of undefined (reading ‘upgrade‘)

前端开发工具&#xff1a;VSCODE 报错信息&#xff1a; INFO Starting development server...10% building 2/2 modules 0 active ERROR TypeError: Cannot read properties of undefined (reading upgrade)TypeError: Cannot read properties of undefined (reading upgrade…...

javaJUC基础

JUC基础知识 多线程 管程 Monitor&#xff0c;也就是平时所说的锁。Monitor其实是一种同步机制&#xff0c;它的义务是保证&#xff08;同一时间&#xff09;只有一个线程可以访问被保护的数据和代码块&#xff0c;JVM中同步是基于进入和退出监视器&#xff08;Monitor管程对…...

std::distance 函数介绍

std::distance 是 C 标准库中的一个函数模板&#xff0c;用于计算两个迭代器之间的距离。它的主要作用是返回从第一个迭代器到第二个迭代器之间的元素数量。这个函数对于不同类型的迭代器&#xff08;如随机访问、双向、前向等&#xff09;都能有效工作。 函数原型 template …...

如何在Windows和Linux之间实现粘贴复制

第一步 sudo apt-get autorremove open-vm-tools第二步 sudo apt-get update第三步 sudo apt-get install open-vm-tools-desktop第四步 一直按Y&#xff0c;希望执行 Y第四步 重启 reboot然后可以实现粘贴复制。...

【第十七章:Sentosa_DSML社区版-机器学习之异常检测】

【第十七章&#xff1a;Sentosa_DSML社区版-机器学习之异常检测】 机器学习异常检测是检测数据集中的异常数据的算子&#xff0c;一种高效的异常检测算法。它和随机森林类似&#xff0c;但每次选择划分属性和划分点&#xff08;值&#xff09;时都是随机的&#xff0c;而不是根…...

【Vue】为什么 Vue 不使用 React 的分片更新?

第一&#xff0c;首先时间分片是为了解决 CPU 进行大量计算的问题&#xff0c;因为 React 本身架构的问题&#xff0c;在默认的情况下更新会进行很多的计算&#xff0c;就算使用 React 提供的性能优化 API&#xff0c;进行设置&#xff0c;也会因为开发者本身的问题&#xff0c…...

大学生科技竞赛系统小程序的设计

管理员账户功能包括&#xff1a;系统首页&#xff0c;个人中心&#xff0c;用户管理&#xff0c;主办方管理&#xff0c;公告栏管理&#xff0c;竞赛分类管理&#xff0c;竞赛信息管理&#xff0c;报名信息管理&#xff0c;竞赛成绩管理 微信端账号功能包括&#xff1a;系统首…...

什么是聚集索引?

什么是聚集索引&#xff1f; 1、聚集索引的特点2、如何确定聚集索引3、性能优势 &#x1f496;The Begin&#x1f496;点点关注&#xff0c;收藏不迷路&#x1f496; 聚集索引是一种特殊的索引&#xff0c;它直接包含了表中的所有数据行。所以&#xff0c;通过聚集索引&#xf…...

Centos/fedora/openEuler 终端中文显示配置

注意&#xff1a;这里主要解决的是图形界面、远程登录界面的中文乱码问题 系统原生的终端&#xff08;如虚拟机系统显示的终端&#xff09;&#xff0c;由于使用的是十分原始的 TTY 终端&#xff0c;使用点阵字体进行显示&#xff0c;点阵字体不支持中文&#xff0c;因此无法显…...

使用kaggle命令下载数据集和模型

点击用户头像&#xff0c;点击Settings&#xff1a; 找到API&#xff0c;点击create new token&#xff0c;将自动下载kaggle.json&#xff1a; 在用户目录下创建.kaggle文件夹&#xff0c;并将下载的kaggle.json文件移动到该文件夹&#xff1a; cd ~ mv Downloads/kaggle.j…...

生信初学者教程(十一):数据校正

介绍 批次效应在生物学数据分析中是一个普遍存在的问题,它指的是由于实验过程中非生物学因素(如样本处理时间、实验条件、测序平台等)的差异,导致实验结果中混入与研究目标不相关的变异。在比较对照组和实验组时,这些非生物学因素可能引入额外的噪声,影响对生物学问题真实…...

JS设计模式之桥接模式:搭建跨越维度的通路

引言 在软件开发中&#xff0c;我们经常遇到需要对不同的抽象类进行不同的实现的情况&#xff0c;而传统的对象嵌套并不是一个优雅且可扩展的解决方案&#xff0c;因此这正是桥接模式的用武之地。桥接模式通过将抽象与实现分离&#xff0c;使得它们可以独立变化&#xff0c;从…...

苹果电脑系统重磅更新——macOS Sequoia 15 系统 新功能一 览

有了 macoS Sequoia&#xff0c;你的工作效率将再次提升&#xff1a;快速调整桌面布局&#xff0c;一目了然地浏览网页重点&#xff0c;还可以通过无线镜像功能操控你的iPhone。 下面就来看看几项出色新功能&#xff0c;还有能够全面发挥这些功能的 App 和游戏。 macOS Sequo…...

DoppelGanger++:面向数据库重放的快速依赖关系图生成

doi&#xff1a;DoppelGanger: Towards Fast Dependency Graph Generation for Database Replay&#xff0c;点击前往 文章目录 1 简介2 架构概述3 依赖关系图3.1 符号和问题定义3.2 无 IT(k) 图3.3 无 OT 图表3.4 无 OTIT 图表3.5 无 IT[OT] 图表3.6 输出确定性保证 4 重复向后…...

Linux(含麒麟操作系统)如何实现多显示器屏幕采集录制

技术背景 在操作系统领域&#xff0c;很多核心技术掌握在国外企业手中。如果过度依赖国外技术&#xff0c;在国际形势变化、贸易摩擦等情况下&#xff0c;可能面临技术封锁和断供风险。开发国产操作系统可以降低这种风险&#xff0c;确保国家关键信息基础设施的稳定运行。在一…...

calibre-web默认左上角字体修改

calibre-web默认左上角字体修改 如图&#xff1a; 有些奇异&#xff0c;如果想变成正常的常规字体&#xff0c;需要修改&#xff1a; cps\static\css\style.css 下的代码&#xff1a; 默认是GrandHotel-Regular&#xff1a; 换成其他字体即可。其他字体在 calibre-web\cps\s…...

考研数据结构——C语言实现归并排序

包含头文件&#xff1a;程序首先包含了标准输入输出库stdio.h&#xff0c;以便使用printf等函数进行输入输出操作。 定义数组和数组大小&#xff1a;定义了一个宏N&#xff0c;其值为5&#xff0c;表示数组q的长度。数组q被初始化为{5, 3, 8, 4, 2}&#xff0c;这是我们要排序…...

LDO功率管选取NMOS和PMOS区别

一、drop电压 LDO如果两个管子流过相同的电流, 假设将管子饱和并顶到接近线性区 NMOS的效率(VIN-VDSAT-VGS)/VIN PMOS的效率&#xff1d;&#xff08;VIN-VDSAT)/VIN 根本原因是 nmos的gate电压比source高vth 如果输出电压(source&#xff09;较高或者驱动电流要大&#xff0c…...

【Linux】进程的标识符、状态(超详解)

目录 进程的概念 进程标识符PID 系统调用创建进程-fork初识 进程状态 R状态&#xff08;运行状态&#xff09; S&#xff0c;D状态&#xff08;休眠状态&#xff09; T&#xff0c;t状态 Z状态&#xff08;僵尸进程&#xff09; 孤儿进程 X状态&#xff08;死亡状态&a…...

Elasticsearch 启动后在浏览器输入http://localhost:9200 访问失败

windows Elasticsearch 启动后在浏览器输入http://localhost:9200 访问失败 文章目录 前言本地下载安装了个elasticsearch&#xff0c;启动成功了&#xff0c;在本地访问http://localhost:9200 无法访问&#xff01;&#xff01;&#xff01;难受了一下。 一、windows Elastics…...

javascript中new操作符的工作原理

在 JavaScript 中&#xff0c;new 操作符用于创建对象的实例。它可以让我们通过构造函数创建一个新的对象&#xff0c;并初始化该对象的属性和方法。尽管 new 操作符的使用很常见&#xff0c;但它在背后实际进行了几个步骤。下面详细解释 new 操作符具体做了哪些事情。 new 操…...

基于springboot+vue 旅游网站的设计与实现

基于springbootvue 旅游网站的设计与实现 摘 要 互联网发展至今&#xff0c;无论是其理论还是技术都已经成熟&#xff0c;而且它广泛参与在社会中的方方面面。它让信息都可以通过网络传播&#xff0c;搭配信息管理工具可以很好地为人们提供服务。针对信息管理混乱&#xff0c…...

Ansible集群服务部署案例

案例描述 本案例共讲述了多个节点部署Elk集群日志分析系统&#xff0c;分别在三个节点使用ansible部署Kibana、Logstash以及Elasticsearch服务。 案例准备 1. 规划节点 IP 主机名 节点 192.168.100.25 ansible Ansible节点 192.168.100.35 node1 Elasticsearch/Kiba…...

探索AI编程新境界:aider库揭秘

文章目录 **探索AI编程新境界&#xff1a;aider库揭秘**背景&#xff1a;为何选择aider&#xff1f;简介&#xff1a;aider是什么&#xff1f;安装指南&#xff1a;如何安装aider&#xff1f;功能演示&#xff1a;aider的简单用法实战应用&#xff1a;aider在不同场景下的使用常…...

SQL Server 2012 ldf日志文接太大的截断和收缩日志处理

SQL Server 2012 ldf日志文接太大的截断和收缩日志处理操作 --- SQL Server 2012 ldf日志文接太大的截断和收缩日志处理 ----- 查看所有 database 列表及详情 select * from sys.databases;-- 切换到指定的操作数据库 use testdb;-- 查询当前数据库的日志文件ID和逻辑文件名 S…...

java日志门面之JCL和SLF4J

文章目录 前言一、JCL1、JCL简介2、快速入门3、 JCL原理 二、SLF4J1、SLF4J简介2、快速入门2.1、输出动态信息2.2、异常信息的处理 3、绑定日志的实现3.1、slf4j实现slf4j-simple和logback3.2、slf4j绑定适配器实现log4j 4、桥接旧的日志框架4.1、log4j日志重构为slf4jlogback的…...

Oracle DB运维常用的视图及数据字典

List item 本文介绍一些Oracle DB日常运维最常用到&#xff08;使用频率很高&#xff09;的视图及数据字典 用户有关的常用视图&#xff1a; 1、 查看当前用户的缺省表空间* SQL>select username,default_tablespace from user_users; 2、 查看当前用户的角色 SQL>sele…...

vue.config.js devServer中changeOrigin的作用

问题 vue开发时&#xff0c;为了解决前端跨域问题&#xff0c;通常在vue.config.js配置 devServer proxy devServer: {proxy:{/api: {target: http://b.com,changeOrigin: false},}, }官方文档http-proxy options对changeOrigin的解释 option.changeOrigin: true/false, Defa…...

基于Ubuntu 20.04 LTS上部署MicroK8s(最小生产的 Kubernetes)

目录 文章目录 目录简介Kubernetes简介MicroK8s简介Ubuntu系统MicroK8s的优势安装环境基本要求执行安装命令加入群组(使用非 root 用户访问)开启 dashboard 仪表盘查看服务名称查看仪表盘开放的端口打开浏览器检查状态打开你想要的服务(使用附加组件)开始使用 microk8s访问 Kub…...