Java后端开发——MVC商品管理程序

news2024/9/28 5:16:07

Java后端开发——MVC商品管理程序

本篇文章内容主要有下面几个部分:

  1. MVC架构介绍
  2. 项目环境搭建
  3. 商品管理模块
  4. Servlet代码重构BaseServlet
  5. 文件上传

MVC 是模型-视图-控制器(Model-View-Controller),它是一种设计模式,也是一种软件架构模式,用于构建用户界面(UI)应用程序。
1.模型(Model):

模型代表应用程序的数据结构和业务逻辑。它负责处理应用程序的数据逻辑部分,包括数据的获取、修改、验证等。

在一个应用程序中,模型可以是一个简单的数据对象,也可以是包含大量业务规则和处理逻辑的复杂对象。

2.视图(View):
视图负责将数据渲染成用户可以看到的界面。它展示了模型的数据给用户,并允许用户与数据进行交互。
在 Web 应用程序中,视图通常是 HTML、CSS 和用户界面组件。

3.控制器(Controller):
控制器是模型和视图之间的中介,它接收用户的输入并处理用户请求。控制器根据用户的请求选择合适的模型进行处理,并将处理结果传递给视图进行显示。
在 Web 应用程序中,控制器通常是处理 HTTP 请求、调度逻辑以及返回 HTTP 响应的代码。

MVC 框架的工作流程

1.用户交互:
用户与应用程序交互,发送请求给控制器。

2.控制器处理请求:
控制器接收到用户的请求,根据请求的类型(GET、POST 等)和参数来决定调用哪个模型处理数据。

控制器可能还需要处理一些逻辑,例如验证用户的输入、选择合适的模型进行处理等。

3.模型处理数据:
模型接收控制器传递过来的数据请求,并进行相应的数据处理,包括数据的获取、更新、存储等操作。

.4.控制器获取处理结果:
模型处理完数据后,将结果返回给控制器。
5.控制器选择视图:
控制器根据模型返回的数据结果,选择合适的视图进行渲染。

6.视图渲染结果:
视图将模型返回的数据渲染成用户可以看到的界面。
7.用户界面更新:
更新后的用户界面展示给用户,用户可以进行下一步操作。

这种分离有利于代码的组织和维护。每个组件都专注于特定的功能,降低了耦合性,使得代码更易于理解、测试和扩展。MVC 模式在各种软件开发中都有广泛的应用,特别是在 Web 开发中,诸如Spring MVC(Java)、Django(Python)、Ruby on Rails(Ruby)等框架中都采用了 MVC 架构。

MVC商品管理程序

项目环境搭建
1.创建数据库db_goods,表goods
在MySQL数据库中创建一个名称为db_goods的数据库,并根据表结构在数据库中创建相应的表。

CREATE TABLE `goods` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `name` VARCHAR(45) DEFAULT NULL,
  `cover` VARCHAR(45) DEFAULT NULL,
  `image1` VARCHAR(45) DEFAULT NULL,
  `image2` VARCHAR(45) DEFAULT NULL,
  `price` FLOAT DEFAULT NULL,
  `intro` VARCHAR(300) DEFAULT NULL,
  `stock` INT DEFAULT NULL,
  `type_id` INT DEFAULT NULL,
  PRIMARY KEY (`id`)
);

在这里插入图片描述
在goods表中插入一些商品数据:
在这里插入图片描述
2.创建项目mygoods,引入JAR包
新建Dynamic web project
在这里插入图片描述
将项目所需JAR包导入到项目的WEB-INF/lib文件夹下。
在这里插入图片描述

3.配置c3p0-config.xml文件
将JAR包导入到项目中并发布到类路径后,在src根目录下新建c3p0-config.xml文件,用于配置数据库连接参数。我的mysql数据库账号和密码都是root.

<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<default-config>
<property name="driverClass">com.mysql.jdbc.Driver</property>
<property name="jdbcUrl">
jdbc:mysql://localhost:3306/db_goods?useSSL=false&amp;serverTimezone=UTC&amp;useUnicode=true&amp;characterEncoding=utf-8
</property>
<property name="user">root</property>
<property name="password">root</property>
<property name="checkoutTimeout">30000</property>
<property name="initialPoolSize">5</property>
<property name="maxIdleTime">30</property>
<property name="maxPoolSize">10</property>
<property name="minPoolSize">2</property>
<property name="maxStatements">200</property>
</default-config>
</c3p0-config>

在这里插入图片描述
4.编写DBUtils工具类
在src下创建一个名称为utils的包,在该包下新建DataSourceUtils类,用于获取数据源和数据库连接。

package com.java.utils;

import java.sql.SQLException;

import javax.sql.DataSource;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.mysql.jdbc.Connection;

public class DataSourceUtils {
    private static DataSource ds=new ComboPooledDataSource();
    public static DataSource getDataSource(){
        return  ds;
    }
	public static Connection getConnection() throws SQLException {
   	   return (Connection) ds.getConnection();
    }
}

在这里插入图片描述
商品管理模块
1.创建Goods.java的JavaBean类

//创建Goods.java的JavaBean类
package com.javaweb.model;

public class Goods {
private int id;
private String name;
private String cover;
private String image1;
private String image2;
private float price;
private String intro;
private int stock;
private int type_id;
//利用工具自动生成Getter/Setter方法
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCover() {
return cover;
}
public void setCover(String cover) {
this.cover = cover;
}
public String getImage1() {
return image1;
}
public void setImage1(String image1) {
this.image1 = image1;
}
public String getImage2() {
return image2;
}
public void setImage2(String image2) {
this.image2 = image2;
}
public float getPrice() {
return price;
}
public void setPrice(float price) {
this.price = price;
}
public String getIntro() {
return intro;
}
public void setIntro(String intro) {
this.intro = intro;
}
public int getStock() {
return stock;
}
public void setStock(int stock) {
this.stock = stock;
}
public int getType_id() {
return type_id;
}
public void setType_id(int type_id) {
this.type_id = type_id;
}
}

在这里插入图片描述
2.创建GoodsDao.java类

package com.javaweb.dao;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import com.java.utils.DataSourceUtils;
import com.javaweb.model.Goods;
public class GoodsDao {
    public List<Goods> findByTypeID(int typeID) throws SQLException {
        if(typeID==0)
        {
            String sql="select * from goods";
            QueryRunner r=new QueryRunner(DataSourceUtils.getDataSource());
            return  r.query(sql,new BeanListHandler<Goods>(Goods.class));
        }
        else
        {
            String sql="select * from goods where type_id=?";
            QueryRunner r=new QueryRunner(DataSourceUtils.getDataSource());
            return  r.query(sql,new BeanListHandler<Goods>(Goods.class),typeID);
        }
    }    
    public List<Goods> findByTypeID(int typeID,int pageNumber,int pageSize) throws SQLException {
        if(typeID==0)
        {
            String sql="select * from goods limit ?,?";
            QueryRunner r=new QueryRunner(DataSourceUtils.getDataSource());
            return  r.query(sql,new BeanListHandler<Goods>(Goods.class),(pageNumber-1)*pageSize,pageSize);
        }
        else
        {
            String sql="select * from goods where type_id=? limit ?,?";
            QueryRunner r=new QueryRunner(DataSourceUtils.getDataSource());
            return  r.query(sql,new BeanListHandler<Goods>(Goods.class),typeID,(pageNumber-1)*pageSize,pageSize);
        }
    }   

    public Goods findById(int id) throws SQLException {
        QueryRunner r = new QueryRunner(DataSourceUtils.getDataSource());
        String sql = "select * from goods where id = ?";
        return r.query(sql, new BeanHandler<Goods>(Goods.class),id);
    }
        
    public int getCountByTypeID(int typeID) throws SQLException {
        String sql="";
        QueryRunner r=new QueryRunner(DataSourceUtils.getDataSource());
        if(typeID==0)
        {
            sql="select count(*) from goods";
            return r.query(sql,new ScalarHandler<Long>()).intValue();
        }
        else
        {
            sql="select count(*) from goods where type_id=?";
            return r.query(sql,new ScalarHandler<Long>(),typeID).intValue();
        }
    }

    public void insert(Goods g) throws SQLException {
        QueryRunner r = new QueryRunner(DataSourceUtils.getDataSource());
        String sql = "insert into goods(name,cover,image1,image2,price,intro,stock,type_id) values(?,?,?,?,?,?,?,?)";
        r.update(sql,g.getName(),g.getCover(),g.getImage1(),g.getImage2(),g.getPrice(),g.getIntro(),g.getStock(),g.getType_id());
    }
    public void update(Goods g) throws SQLException {
        QueryRunner r = new QueryRunner(DataSourceUtils.getDataSource());
        String sql = "update goods set name=?,cover=?,image1=?,image2=?,price=?,intro=?,stock=?,type_id=? where id=?";
        r.update(sql,g.getName(),g.getCover(),g.getImage1(),g.getImage2(),g.getPrice(),g.getIntro(),g.getStock(),g.getType_id(),g.getId());
    }
    public void delete(int id) throws SQLException {
        QueryRunner r = new QueryRunner(DataSourceUtils.getDataSource());
        String sql = "delete from goods where id = ?";
        r.update(sql,id);
    }
    
}

在这里插入图片描述
3.创建goods_add.jsp表单页

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.css" />
</head>
<body>
<div class="container-fluid">
<h3>添加商品页面</h3>
<br><br>
<form class="form-horizontal" action="${pageContext.request.contextPath}/GoodsServlet?m=add" method="post">
<div class="form-group">
<label for="input_name" class="col-sm-1 control-label">名称</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="input_name" name="name" required="required">
</div>
</div>
<div class="form-group">
<label for="input_name" class="col-sm-1 control-label">价格</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="input_name" name="price" >
</div>
</div>
<div class="form-group">
<label for="input_name" class="col-sm-1 control-label">介绍</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="input_name" name="intro" >
</div>
</div>
<div class="form-group">
<label for="input_name" class="col-sm-1 control-label">库存</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="input_name" name="stock" >
</div>
</div>
<div class="form-group">
<label for="input_file" class="col-sm-1 control-label">封面图片</label>
<div class="col-sm-6">
<input type="text" name="cover" id="input_file" required="required">推荐尺寸: 500 * 500
</div>
</div>
<div class="form-group">
<label for="input_file" class="col-sm-1 control-label">详情图片1</label>
<div class="col-sm-6">
<input type="text" name="image1" id="input_file" required="required">推荐尺寸: 500 * 500
</div>
</div>
<div class="form-group">
<label for="input_file" class="col-sm-1 control-label">详情图片2</label>
<div class="col-sm-6">
<input type="text" name="image2" id="input_file" required="required">推荐尺寸: 500 * 500
</div>
</div>
<div class="form-group">
<label for="select_topic" class="col-sm-1 control-label">类目</label>
<div class="col-sm-6">
<select class="form-control" id="select_topic" name="type_id">
<option value="1">食品</option>
<option value="2">生活用品</option>
<option value="3">学习用品</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<button type="submit" class="btn btn-success">提交保存</button>
</div>
</div>
</form>
</div>
</body>
</html>

在这里插入图片描述
4.创建GoodServlet.java,根据请求参数m的值调用增删改查方法

@WebServlet("/GoodsServlet")
public class GoodsServlet extends HttpServlet {
	
	GoodsDao goodsDao=new GoodsDao();

	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String m=request.getParameter("m");
		if(m.equals("add")) {
			add(request,response);
		}else if(m.equals("find")) {
			find(request,response);
		}else if(m.equals("update")) {
			update(request,response);
		}else if(m.equals("delete")) {
			delete(request,response);
		}else if(m.equals("findById")) {
			findById(request,response);
		}
	}
}

5.完善GoodServlet的商品增加add方法

private void add(HttpServletRequest request, HttpServletResponse response) {
Goods goods = new Goods();
try {
BeanUtils.populate(goods,request.getParameterMap());
goodsDao.insert(goods);
response.sendRedirect("GoodsServlet?m=find");
} catch (Exception e) {
e.printStackTrace();
} 

在这里插入图片描述
6.测试商品保存
运行tomact服务器,添加一条商品信息:
在这里插入图片描述
提交保存,再查看所有商品信息页,发现添加商品测试成功!
在这里插入图片描述
7.完善GoodServlet的商品查询find方法。

private void find(HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
int type = 0;//推荐类型
if(request.getParameter("type") != null) {
type=Integer.parseInt(request.getParameter("type") ) ;
}
try {
List<Goods> glist=goodsDao.findByTypeID(type);
request.setAttribute("glist", glist);
request.getRequestDispatcher("/goods_list.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}

在这里插入图片描述
8.创建商品列表页面goods_list.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.css" />
</head>
<body>
<div class="container-fluid">
<h3>商品列表页面</h3>
<div class="text-right"><a class="btn btn-warning" href="goods_add.jsp">添加商品</a></div>
<table class="table table-bordered table-hover">
<tr>
<th width="5%">ID</th>
<th width="10%">名称</th>
<th width="10%">价格</th>
<th width="10%">介绍</th>
<th width="10%">库存</th>
<th width="10%">封面图片</th>
<th width="10%">详情图片1</th>
<th width="10%">详情图片2</th>
<th width="10%">类目</th>
<th width="10%">操作</th>
</tr>
<c:forEach items="${glist }" var="g">
<tr>
<td><p>${g.id }</p></td>
<td><p>${g.name }</p></td>
<td><p>${g.price }</p></td>
<td><p>${g.intro }</p></td>
<td><p>${g.stock }</p></td>
<td><p>${g.cover }</p></td>
<td><p>${g.image1 }</p></td>
<td><p>${g.image2}</p></td>
<td><p>${g.type_id }</p></td>
<td>
<a class="btn btn-primary" href="${pageContext.request.contextPath}/GoodsServlet?m=findById&id=${g.id}">修改</a>
<a class="btn btn-danger" href="${pageContext.request.contextPath}/GoodsServlet?m=delete&id=${g.id}">删除</a>
</td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>

9.测试商品查询全部
运行tomact服务,运行goods_list.jsp文件然后在网页find路由

http://localhost:8080/mygoods/GoodsServlet?m=find

查询商品全部信息。
在这里插入图片描述
在这里插入图片描述
10.完善GoodServlet的商品按ID查询findById方法

private void findById(HttpServletRequest request, HttpServletResponse response) {
int id=Integer.parseInt(request.getParameter("id"));
try {
Goods g= goodsDao.findById(id);
request.setAttribute("g", g);
request.getRequestDispatcher("/goods_edit.jsp").forward(request, response);
} catch (Exception e) {
e.printStackTrace();
}
}

在这里插入图片描述
在这里插入图片描述
11.创建商品列表页面goods_edit.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="css/bootstrap.css" />
</head>
<body>
<div class="container-fluid">
<h3>修改商品页面</h3>
<br><br>
<form class="form-horizontal" action="${pageContext.request.contextPath}/GoodsServlet?m=update" method="post">
<input type="hidden" name="id" value="${g.id }"/> 
<div class="form-group">
<label for="input_name" class="col-sm-1 control-label">名称</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="input_name" name="name" value="${g.name }" required="required">
</div>
</div>
<div class="form-group">
<label for="input_name" class="col-sm-1 control-label">价格</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="input_name" value="${g.price }" name="price" >
</div>
</div>
<div class="form-group">
<label for="input_name" class="col-sm-1 control-label">介绍</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="input_name" value="${g.intro }" name="intro" >
</div>
</div>
<div class="form-group">
<label for="input_name" class="col-sm-1 control-label">库存</label>
<div class="col-sm-6">
<input type="text" class="form-control" id="input_name" name="stock" value="${g.stock }">
</div>
</div>
<div class="form-group">
<label for="input_file" class="col-sm-1 control-label">封面图片</label>
<div class="col-sm-6">
<input type="text" name="cover" id="input_file" value="${g.cover }" required="required">推荐尺寸: 500 * 500
</div>
</div>
<div class="form-group">
<label for="input_file" class="col-sm-1 control-label">详情图片1</label>
<div class="col-sm-6">
<input type="text" name="image1" id="input_file" value="${g.image1 }" required="required">推荐尺寸: 500 * 500
</div>
</div>
<div class="form-group">
<label for="input_file" class="col-sm-1 control-label">详情图片2</label>
<div class="col-sm-6">
<input type="text" name="image2" id="input_file" value="${g.image2 }" required="required">推荐尺寸: 500 * 500
</div>
</div>
<div class="form-group">
<label for="select_topic" class="col-sm-1 control-label">类目</label>
<div class="col-sm-6">
<select class="form-control" id="select_topic" value="${g.type_id }" name="type_id">
<option value="1" ${g.type_id==1?'selected="selected"':''}>食品</option>
<option value="2" ${g.type_id==2?'selected="selected"':''}>生活用品</option>
<option value="3" ${g.type_id==3?'selected="selected"':''}>学习用品</option>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-1 col-sm-10">
<button type="submit" class="btn btn-success">提交保存</button>
</div>
</div>
</form>
</div>
</body>
</html>

在这里插入图片描述
12.测试商品更新
启动tomact服务器,

http://localhost:8080/mygoods/GoodsServlet?m=findById&id=2

对id为2的商品进行修改。
修改之前的数据:
在这里插入图片描述
进行修改:
在这里插入图片描述
修改之后的数据:
在这里插入图片描述
13.完善GoodServlet的商品删除delete方法

private void delete(HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
int id=Integer.parseInt(request.getParameter("id"));
try {
goodsDao.delete(id);
response.sendRedirect("GoodsServlet?m=find");
} catch (Exception e) {
e.printStackTrace();
} 
}

在这里插入图片描述
14.测试商品删除
我们在所有商品页面把id为168和169的商品删除:
在这里插入图片描述
点击删除,成功调用delete方法删除两条记录:
在这里插入图片描述
15.创建编码过滤器,解决表单中文乱码
为防止项目中请求和响应出现乱码情况,在src下创建一个名称为filter的包,在该包下新建一个过滤器EncodeFilter类来统一全站的编码,防止出现乱码的情况。

package com.javaweb.filter;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;

/**
 * Servlet Filter implementation class EncodeFilter
 */
@WebFilter("/*")
public class EncodeFilter extends HttpFilter implements Filter {

	/**
	 * @see Filter#destroy()
	 */
	public void destroy() {
		// TODO Auto-generated method stub
	}

	/**
	 * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
	 */
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
		request.setCharacterEncoding("utf-8");
		chain.doFilter(request, response);
	}

	/**
	 * @see Filter#init(FilterConfig)
	 */
	public void init(FilterConfig fConfig) throws ServletException {
		// TODO Auto-generated method stub
	}

}

在这里插入图片描述
Servlet代码重构BaseServlet
1.编写BaseServlet,实现Java动态方法调用

package com.javaweb.servlet;

import java.io.IOException;
import java.lang.reflect.Method;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class BaseServlet extends HttpServlet {
	    @Override
	    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
	        String m = req.getParameter("m");
	        Class  clazz = this.getClass();
	        try {
	            Method method = clazz.getDeclaredMethod(m, HttpServletRequest.class, HttpServletResponse.class);
	            method.setAccessible(true);
	            method.invoke(this,req,resp);
	        } catch (Exception e) {
	            e.printStackTrace();
	        } 
	    }
	}

在这里插入图片描述
2.修改GoodServlet继承BaseServlet
将之前的HttpServlet修改为BaseServlet

public class GoodsServlet extends BaseServlet {
private static final long serialVersionUID = 1L;
GoodsDao goodsDao=new GoodsDao();

在这里插入图片描述
3.测试功能是否正常
服务器启动正常,测试正常可以正常增删改查
在这里插入图片描述
增加一条“西瓜波波”商品信息:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
我们修改西瓜波波价格从12改成15:
在这里插入图片描述
修改成功!
在这里插入图片描述
删除西瓜波波这条商品信息,删除成功,在所有商品信息页查找不到此商品!
在这里插入图片描述
通过测试,所有功能均正常!
文件上传
1.创建上传表单页
新建upload.jsp上传表单页
在这里插入图片描述
2.编写上传upload方法

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="${pageContext.request.contextPath}/GoodsServlet?m=upload" method="post" enctype="multipart/form-data">
商品名称:<input type="text" name="name">
商品图片:<input type="file" name="photo">
<input type="submit" value="上传">
</form>

</body>
</html>

在这里插入图片描述
3.测试
启动tomact服务器,运行upload.jsp文件开始进行文件上传
在这里插入图片描述
上传商品名称为1 ,上传图片名称为“图片.jpg”
在这里插入图片描述

在这里插入图片描述
点击上传,控制台信息显示:
1 | ec996c8a-33cc-4dd4-a344-8fec1d008b4a.jpg
文件上传成功!
在这里插入图片描述
然后打开本地目录:
C:\myx\java后端\MVC商品管理程序.metadata.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\mygoods\upload

成功发现我们在upload,jsp页面上传的文件:
在这里插入图片描述
希望各位能通过MVC商品管理程序认识MVC框架的重要性,它可以有效地分离业务逻辑和视图层,使得代码更加清晰易懂。

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

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

打破限制!MySQL 5.7至8.0跨版本迁移,1分钟搞定多版本数据迁移

在上个月&#xff0c;MySQL 5.7 正式结束了生命周期&#xff0c;即EOL&#xff08;End of Life&#xff09;&#xff0c;意味着Oracle将不再为 MySQL 5.7 提供技术支持&#xff0c;包括Bug修复或安全漏洞&#xff0c;大大增加了使用数据库的风险。在全球关系型数据库市场中&…

WinMerge使用教程,WinMerge下载

一、下载 官方下载 WinMerge - You will see the difference… 官方地址&#xff1a;https://winmerge.org/ 阿里云盘下载 文件内容对比工具WinMerge2.16.25.25 https://www.alipan.com/s/r7MzudB235x 点击链接保存&#xff0c;或者复制本段内容&#xff0c;打开「阿里云盘…

Webpack——Webpack简介

1、什么是Webpack&#xff1f; Webpack是一个开源的JavaScript模块打包工具&#xff0c;其最核心的功能是解决模块之间的依赖&#xff0c;把各个模块按照特定的规则和顺序组织在一起&#xff0c;最终合并为一个JS文件&#xff08;有时会有多个&#xff0c;这里讨论的只是最基本…

【Cisco Packet Tracer】构造超网

​​&#x1f308;个人主页&#xff1a;Sarapines Programmer&#x1f525; 系列专栏&#xff1a;《Cisco Packet Tracer | 奇遇记》⏰寄 语&#xff1a;风翻云浪激&#xff0c;剑舞星河寂。 临风豪情壮志在&#xff0c;拨云见日昂首立。 目录 ⛳️1. Cisco Packet Trace…

【JavaEE初阶】 HTTP协议和使用Fiddler抓包

文章目录 &#x1f38d;HTTP协议是什么&#xff1f;&#x1f340;应用层协议&#xff08;HTTP&#xff09;存在的意义&#x1f384;HTTP 协议的工作过程&#x1f334;HTTP 协议格式&#x1f333;Fiddler抓包工具的使用&#x1f6a9;如何抓HTTPS的包&#xff1f; &#x1f38b;抓…

影刀实例二,小某书如何持续下载图片

一&#xff0c;案例背景&#xff1a; 小某书平台&#xff0c;利用影刀rpa搜索关键词&#xff0c;然后下载对应文章的图片. 二&#xff0c;思路 1. 登录小某书平台&#xff0c;将网页放大最大【手动完成&#xff0c;作为初始状态】 2. 利用影刀命令【打开输入对话框】获得要搜索…

如何解决中小制造业企业信息化难题?

中小企的信息化&#xff0c;难&#xff01; 一、中小制造业企业信息化困难的原因主要有以下几点&#xff1a; 资金限制&#xff1a;中小制造业企业相对于大型企业来说资金有限&#xff0c;无法投入大量资金进行信息化建设。技术水平不足&#xff1a;中小制造业企业缺乏专业的…

分享一款4G低功耗摄像头接入物联网平台解决方案

首先介绍硬件方案&#xff1a; 应用场景-4G低功耗摄像头 该方案中&#xff0c;Module为G8100B&#xff08;4G模块&#xff09;&#xff0c;HOST为海思摄像头(Linux or LiteOS)&#xff0c;G8100B的USB可以在Host端虚拟出串口和网卡&#xff0c;G8100B符合以下条件进入休眠&…

基于单片机的大棚温湿度检测系统(论文+源码)

1. 系统设计 本课题主要开发一个大棚温湿度检测系统、其功能要求如下&#xff1a; 1.实现大棚温室环境的空气中的温湿度检测&#xff1b; 2.当检测到的土壤湿度低于阈值时&#xff0c;模拟水泵进行浇水&#xff0c;湿度太高则进行干燥&#xff1b; 4. 当检测到环境的温度太…

从零开始搭建博客网站-----构建项目

构建项目 视频参考链接 构建一个项目文件&#xff08;node为17.16.0版本&#xff09; 构建的过程中可能会出现一个选项&#xff0c;选择vueJavaScript npm init vitelatest easyblog-front-admin安装相关依赖 cd easyblog-front-admin npm install3. 运行 npm run dev好了…

反转链表的三种写法

题目链接&#xff1a;https://leetcode.cn/problems/reverse-linked-list/ 方法一&#xff1a;循环&#xff0c;维护好两个节点一个前一个后 class Solution {public ListNode reverseList(ListNode head) {ListNode pre null;ListNode local head;while(local ! null){List…

GUI加分游戏

需求目标 这个简单的游戏窗口包含一个得分标签和一个按钮。每次点击按钮时&#xff0c;得分增加1&#xff0c;并更新得分标签的显示。 效果 源码 /*** author lwh* date 2023/11/28* description 这个简单的游戏窗口包含一个得分标签和一个按钮。每次点击按钮时&#xff0c;…

python爱心代码高级

在Python中&#xff0c;我们可以使用matplotlib库来创建一个更高级的爱心图形。以下是一个示例&#xff1a; import matplotlib.pyplot as pltimport numpy as npx np.linspace(-2, 2, 1000)y1 np.sqrt(1-(abs(x)-1)**2)y2 -3*np.sqrt(1-(abs(x)/2)**0.5)fig, ax plt.subp…

Docker Swarm总结+service创建和部署、overlay网络以及Raft算法(2/5)

博主介绍&#xff1a;Java领域优质创作者,博客之星城市赛道TOP20、专注于前端流行技术框架、Java后端技术领域、项目实战运维以及GIS地理信息领域。 &#x1f345;文末获取源码下载地址&#x1f345; &#x1f447;&#x1f3fb; 精彩专栏推荐订阅&#x1f447;&#x1f3fb;…

CentOS 系列:CentOS 7文件系统的组成

CentOS 7文件系统的组成 文件系统的组成Linux的一些重要目录文件和目录名主机名文件权限绝对路径和相对路径绝对路径相对路径 文件系统的组成 一切从根开始 文件路径中只有第一个/是根目录&#xff0c;后面的/是分隔符 文件名区分大小写 除斜线(/)以外&#xff0c;其他的字符…

基于HTML+CSS+JavaScript的登录注册界面设计

一、界面效果: 二、HTML代码: 登录注册html: 登录成功html: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <h1>登录成功!</h1> </body> <…

共筑关基安全防线,开源网安加入中关村华安关键信息基础设施安全保护联盟

近日&#xff0c;开源网安正式加入“中关村华安关键信息基础设施安全保护联盟”&#xff08;以下简称&#xff1a;关保联盟&#xff09;成为会员单位&#xff0c;进一步加强与行业内重要机构、企业的协同合作&#xff0c;推动关键信息基础设施安全保护领域的生态建设。 未来&am…

【vue ui 一直卡在 Starting GUI..】

vue ui 解决问题 1.如果项目一直卡在 Starting GUI..2.解决方法 (切换数据源)3.成功解决 1.如果项目一直卡在 Starting GUI… 2.解决方法 (切换数据源) 直接在cmd中输入如下 npm config set registry http://registry.npm.taobao.org/3.成功解决

免单优选模式,新型电商革命的未来趋势!

​小编介绍&#xff1a;10年专注商业模式设计及软件开发&#xff0c;擅长企业生态商业模式&#xff0c;商业零售会员增长裂变模式策划、商业闭环模式设计及方案落地&#xff1b;扶持10余个电商平台做到营收过千万&#xff0c;数百个平台达到百万会员&#xff0c;欢迎咨询。 在…

Go字符串类型

一、字符串 1、字符串 Go 语言里的字符串的内部实现使用 UTF-8 编码字符串带的值为双引号&#xff08;"&#xff09;中的内容&#xff0c;可以在 Go 语言的源码中直接添加非ASCII 码字符 s1 : "hello" s2 : "您好" 2、字符串转义符 Go 语言的字符…