基于JSP、java、Tomcat三者的项目实战--校园交易平台系统--(实习,答辩皆可用到)--万字爆更

news2024/9/22 15:35:04

技术支持:JAVA、JSP

服务器:TOMCAT 7.0.86

编程软件:IntelliJ IDEA 2021.1.3 x64

全部文件展示

网页实现功能截图

主页

注册 

 登录

购物车主页

修改功能

修改成功

添加商品功能 

添加成功

添加进入购物车功能

支付功能

 支付过的历史清单账单


全部代码

dao->StudentDAO

package dao;

import entiy.Product;
import entiy.Student;
import entiy.Total;
import util.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class StudentDAO {
    public List<Student> findAll() throws Exception {
        List<Student> students = new ArrayList<Student>();
        Connection conn = null;
        PreparedStatement prep = null;
        ResultSet rst = null;
        try {
            conn = DBUtil.getConnection();
            prep = conn.prepareStatement("select * from users");
            rst = prep.executeQuery();
            while (rst.next()) {
                int id = rst.getInt("id");
                String name = rst.getString("name");
                int idname = rst.getInt("idname");
                String pd = rst.getString("pd");
                Student e1 = new Student();
                e1.setName(name);
                e1.setIdname(idname);
                e1.setPd(pd);
                students.add(e1);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        } finally {
            DBUtil.close(conn);
        }

        return students;
    }
    public List<Product> findAllgoods() throws Exception {
        List<Product> products = new ArrayList<Product>();
        Connection conn = null;
        PreparedStatement prep = null;
        ResultSet rst = null;
        try {
            conn = DBUtil.getConnection();
            prep = conn.prepareStatement("select * from goods");
            rst = prep.executeQuery();
            while (rst.next()){
                int id = rst.getInt("id");
                String name = rst.getString("name");
                double price = rst.getDouble("price");
                Product e1 = new Product();
                e1.setId(id);
                e1.setName(name);
                e1.setPrice(price);
                products.add(e1);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw  e;
        }finally {
            DBUtil.close(conn);
        }

        return products;
    }
    public List<Total> findtotals() throws Exception {
        List<Total> totals = new ArrayList<Total>();
        Connection conn = null;
        PreparedStatement prep = null;
        ResultSet rst = null;
        try {
            conn = DBUtil.getConnection();
            prep = conn.prepareStatement("select * from Total");
            rst = prep.executeQuery();
            while (rst.next()){
                int id = rst.getInt("id");
                double total = rst.getDouble("total");
                Total e1 = new Total();
                System.out.println(e1);
                e1.setId(id);
                e1.setTotal(total);
                totals.add(e1);
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw  e;
        }finally {
            DBUtil.close(conn);
        }

        return totals;
    }
    public void save(Student e) throws Exception {
        Connection conn = null;
        PreparedStatement prep = null;
        try {
            conn = DBUtil.getConnection();
            prep = conn.prepareStatement(
                    "INSERT INTO users (name, idname, pd) VALUES (?, ?, ?)");
            prep.setString(1, e.getName());
            prep.setInt(2, e.getIdname());
            prep.setString(3, e.getPd());
            prep.executeUpdate();
        } catch (Exception e1) {
            e1.printStackTrace();
            throw e1;
        } finally {
            // Close PreparedStatement and Connection
            if (prep != null) {
                try {
                    prep.close();
                } catch (SQLException e2) {
                    e2.printStackTrace();
                }
            }
            DBUtil.close(conn);
        }
    }
    public void savegoods(Product e) throws Exception {
    Connection conn = null;
    PreparedStatement prep = null;
    try {
        conn = DBUtil.getConnection();
        prep = conn.prepareStatement(
                "INSERT INTO goods (name,price) VALUES (?, ?)");
        prep.setString(1, e.getName());
        prep.setDouble(2, e.getPrice());
        prep.executeUpdate();
    } catch (SQLException e1) {
        // Handle specific SQL exceptions or log them for debugging
        e1.printStackTrace();
        throw new Exception("Failed to save goods: " + e1.getMessage(), e1);
    } finally {
        // Close PreparedStatement and Connection in finally block
        if (prep != null) {
            try {
                prep.close();
            } catch (SQLException e2) {
                e2.printStackTrace();
            }
        }
        DBUtil.close(conn);
    }
}
    public void delete(int id) throws Exception {
        Connection conn =null;
        PreparedStatement prep = null;
        try {
            conn = DBUtil.getConnection();
            prep = conn.prepareStatement("delete from emp where id="+id+"");
            prep.executeUpdate();
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }finally {
            DBUtil.close(conn);
        }
    }
    //根据ID查询商品信息(修改商品信息第一步)
    public Product findById(int id) throws Exception{
        Connection conn = null;
        PreparedStatement prep = null;
        ResultSet rst = null;
        Product e =new Product();
        try {
            conn =DBUtil.getConnection();
            System.out.println(conn);
            prep = conn.prepareStatement(
                    "select * from goods where id="+id+"");
            System.out.println(id);
            rst = prep.executeQuery();
            if(rst.next()){
                int id1 = rst.getInt("id");
                String name = rst.getString("name");
                Double price = rst.getDouble("price");
                e.setId(id1);
                e.setName(name);
                e.setPrice(price);
            }
        }catch (Exception e1){
            e1.printStackTrace();
            throw e1;
        }finally {
            DBUtil.close(conn);
        }
        return e;
    }
    public void Update(int id,String name,double price) throws Exception {
        Connection connection = DBUtil.getConnection();
        PreparedStatement preparedStatement = connection.prepareStatement("update goods set name=?,price=? where id =?;");
        preparedStatement.setString(1,name);
        preparedStatement.setDouble(2,price);
        preparedStatement.setInt(3,id);

        int i = preparedStatement.executeUpdate();
        connection.close();
    }
    public void totalprice(Total e) throws Exception {
        Connection conn = null;
        PreparedStatement prep = null;
        try {
            conn = DBUtil.getConnection();
            prep = conn.prepareStatement(
                    "INSERT INTO Total (total) VALUES (?)");
            prep.setDouble(1, e.getTotal());
            prep.executeUpdate();
        } catch (Exception e1) {
            e1.printStackTrace();
            throw e1;
        } finally {
            // Close PreparedStatement and Connection
            if (prep != null) {
                try {
                    prep.close();
                } catch (SQLException e2) {
                    e2.printStackTrace();
                }
            }
            DBUtil.close(conn);
        }
    }
    public static void main(String[] args) throws Exception {
       /* StudentDAO dao = new StudentDAO();
        Student e = new Student();
        e.setName("ww");
        e.setIdname(Integer.parseInt("123"));
        e.setPd("123");
        dao.save(e);
        System.out.println(e);
        */

    }
}

entity->CarItem ->Product -> Student ->Total 

package entiy;

// 可选的购物车条目类
public class CarItem {
    private Product product;
    private int quantity;
    // 其他属性

    // 构造方法、getter和setter方法

    public CarItem(Product product, int quantity /*, 其他属性 */) {
        this.product = product;
        this.quantity = quantity;
        // 初始化其他属性
    }

    public Product getProduct() {
        return product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    public int getQuantity() {
        return quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    @Override
    public String toString() {
        return "CarItem{" +
                "product=" + product +
                ", quantity=" + quantity +
                '}';
    }
}
package entiy;

public class Product {
    private int id;
    private String name;
    private double price;
    // 其他商品属性,如颜色、库存等

    // 构造方法、getter和setter方法


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Product(/*, 其他属性 */) {
        this.name = name;
        this.price = price;
        // 初始化其他属性
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() { return price; }

    public void setPrice(double price) {
        this.price = price;
    }

    @Override
    public String toString() {
        return "Product{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", price=" + price +
                '}';
    }
}
package entiy;

public class Student {

    private String name;
    private int idname;
    private String pd;

    public String getName(){
        return name;
    }
    public void setName(String name){
        this.name=name;
    }

    public int getIdname(){
        return idname;
    }
    public void setIdname(int idname){
        this.idname = idname;
    }

    public String getPd(){
        return pd;
    }
    public void setPd(String pd){
        this.pd = pd;
    }

    @Override
    public String toString(){
        return "Student{"+
                "name="+name+
                "idname="+idname+
                ",pd="+pd+
                '}';
    }

}


package entiy;

public class Total {
    private double total;
    private int id;

    public void setId(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public Total(/*, 其他属性 */) {
        this.total = total;
        this.id = id;
        // 初始化其他属性
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public double getTotal() {
        return total;
    }

    @Override
    public String toString() {
        return "Total{" +
                "total=" + total +
                ", id=" + id +
                '}';
    }
}


Servlet包下的许多服务 

 以下按顺序排列

package Servlet;

import dao.StudentDAO;
import entiy.Product;
import entiy.Student;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class AddShoppingServlet extends HttpServlet {
    public void service(HttpServletRequest request,
                        HttpServletResponse response)

            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        //读取参数
        String name = request.getParameter("name");
        String price = request.getParameter("price");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();
        try {
            StudentDAO dao = new StudentDAO();
            //创建商品对象
            Product e1 = new Product();
            e1.setName(name);
            e1.setPrice(Double.parseDouble(price));
            System.out.println(e1.getName());
            System.out.println(e1.getPrice());
            dao.savegoods(e1);
            //重定向到主页面
            response.sendRedirect("list");
        } catch (Exception e) {
            e.printStackTrace();
            out.println("系统繁忙,请稍后再试!");
        }
        out.close();
    }
}

 

package Servlet;

import dao.StudentDAO;
import entiy.Product;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
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;

public class listServlet extends HttpServlet {
    public void service(HttpServletRequest request,
                        HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        try {
            StudentDAO dao = new StudentDAO();
            List<Product> products = dao.findAllgoods();
            request.setAttribute("goods",products);
            RequestDispatcher rd = request.getRequestDispatcher("shopping.jsp");
            rd.forward(request,response);
        } catch (Exception e) {
            e.printStackTrace();
            out.println("系统繁忙,请稍后再试!");
        }
    }
}
package Servlet;

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class LoginServlet extends HttpServlet {
    // 数据库连接信息(这里假设你使用MySQL数据库)
    private String jdbcURL = "jdbc:mysql://localhost:3306/sdjyy";
    private String jdbcUsername = "root";
    private String jdbcPassword = "asd123";

    protected void doPost(
            HttpServletRequest request,
            HttpServletResponse response) throws ServletException, IOException {
        // 获取登录页面提交的账号和密码
        String username = request.getParameter("idname");
        String password = request.getParameter("pd");
        System.out.println(username);
        System.out.println(password);

        // 假设这里是你的登录逻辑,可以是数据库验证等
        boolean isValidUser = false;
        try {
            isValidUser = checkUser(username, password);
        } catch (Exception e) {
            e.printStackTrace();
        }
        // 这里进行账号密码验证的逻辑,比如查询数据库
        // 注意:这里应该使用 PreparedStatement 或其他安全方式来避免 SQL 注入攻击

        // 示例中简单输出账号密码到控制台
        System.out.println("Username: " + username);
        System.out.println("Password: " + password);

        if (isValidUser) {
            // 登录成功,重定向到商品页面
            HttpSession session = request.getSession();
            session.setAttribute("username", username);
            response.sendRedirect("list");
        } else {
            // 登录失败,可以返回到登录页面或者给出错误信息
            response.sendRedirect("denglu.jsp?error=1"); // 假设带有错误参数
        }
    }

    // 模拟用户验证,实际情况应根据你的业务逻辑实现
    private boolean checkUser(String username, String password) throws Exception {
        try {
            // 加载数据库驱动程序
            Class.forName("com.mysql.jdbc.Driver");
            // 连接数据库
            Connection connection = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);

            // 查询语句
            String sql = "SELECT * FROM users WHERE idname = ? AND pd = ?";
            PreparedStatement statement = connection.prepareStatement(sql);
            statement.setString(1, username);
            statement.setString(2, password);
            System.out.println(username);
            System.out.println(password);

            // 执行查询
            ResultSet result = statement.executeQuery();

            // 如果查询到结果集,说明用户名和密码匹配
            if (result.next()) {
                return true;
            }

            // 关闭连接
            connection.close();
        } catch (SQLException | ClassNotFoundException e) {
            e.printStackTrace();
        }
        // 如果没有查询到结果或者出现异常,则验证失败
        return false;
    }
}

 

package Servlet;

import dao.StudentDAO;
import entiy.Total;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
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;

public class LSQDServlet extends HttpServlet {
    public void service(HttpServletRequest request,
                        HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        try {
            StudentDAO dao = new StudentDAO();
            List<Total> totals = dao.findtotals();
            request.setAttribute("total",totals);
            RequestDispatcher rd = request.getRequestDispatcher("Checkout.jsp");
            rd.forward(request,response);
        } catch (Exception e) {
            e.printStackTrace();
            out.println("系统繁忙,请稍后再试!");
        }
    }
}
package Servlet;

import dao.StudentDAO;
import entiy.Product;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class SelectShoppingServlet extends HttpServlet {
    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        StudentDAO studentDAO = new StudentDAO();
        String id = request.getParameter("id");
        System.out.println(id);
        PrintWriter writer = response.getWriter();
        try {
            Product product = studentDAO.findById(Integer.parseInt(id));
            request.setAttribute("goods",product );
            RequestDispatcher rd = request.getRequestDispatcher("Update.jsp");
            rd.forward(request,response);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
package Servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;

public class ShoppingServlet extends HttpServlet {
    // 数据库连接信息(这里假设你使用MySQL数据库)
    private String jdbcURL = "jdbc:mysql://localhost:3306/sdjyy";
    private String jdbcUsername = "root";
    private String jdbcPassword = "asd123";

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession();
        String idname = (String) session.getAttribute("idname");

        if (idname != null) {
            // 如果成功获取到 idname,可以继续处理逻辑
            // 在这里可以根据 idname 进行数据库查询或者其他业务逻辑

            Connection conn = null;
            PreparedStatement stmt = null;
            ResultSet rs = null;

            try {
                conn = DriverManager.getConnection(jdbcURL, jdbcUsername, jdbcPassword);

                String sql = "SELECT * FROM users WHERE idname = ?";
                stmt = conn.prepareStatement(sql);
                stmt.setString(1, idname);

                rs = stmt.executeQuery();

                if (rs.next()) {
                    // 从结果集中获取其他信息或者执行其他操作
                    String username = rs.getString("idname");
                    System.out.println("Username retrieved: " + username);

                    // 将用户名存储到 session 中(如果需要的话)
                    session.setAttribute("username", username);

                    // 转发到 shopping.jsp 页面或者其他需要的页面
                    RequestDispatcher dispatcher = request.getRequestDispatcher("/shopping.jsp");
                    dispatcher.forward(request, response);
                } else {
                    // 如果未能从数据库中找到对应的记录,处理逻辑(例如跳转到错误页面)
                    response.sendRedirect("/denglu.jsp");
                }

            } catch (SQLException se) {
                se.printStackTrace();
                response.getWriter().println("数据库连接错误");
            } finally {
                // 关闭资源
                try {
                    if (rs != null) rs.close();
                    if (stmt != null) stmt.close();
                    if (conn != null) conn.close();
                } catch (SQLException se) {
                    se.printStackTrace();
                }
            }
        } else {
            // 如果未能成功取 idname,处理逻辑(例如跳转到登录页面或者错误页面)
            response.sendRedirect("/denglu.jsp");
        }
    }
}
package Servlet;

import dao.StudentDAO;
import entiy.Product;
import entiy.Total;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class TotalServlet extends HttpServlet {
    public void service(HttpServletRequest request,
                        HttpServletResponse response)

            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String total = request.getParameter("total");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();
        try {
            StudentDAO dao = new StudentDAO();
           Total e1 = new Total();
            e1.setTotal(Double.parseDouble(total));

            System.out.println(e1.getTotal());
            dao.totalprice(e1);
            response.sendRedirect("list");
        } catch (Exception e) {
            e.printStackTrace();
            out.println("系统繁忙,请稍后再试!");
        }
        out.close();
    }
}
package Servlet;

import dao.StudentDAO;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class UpdateShoppingServlet extends HttpServlet {
    public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
        StudentDAO productDAO = new StudentDAO();
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        // Get parameters from request
        String idStr = request.getParameter("id");
        String name = request.getParameter("name");
        String priceStr = request.getParameter("price");

        // Validate parameters
        if (idStr == null || name == null || priceStr == null || idStr.isEmpty() || name.isEmpty() || priceStr.isEmpty()) {
            response.getWriter().println("Invalid parameters. Please provide all fields.");
            return;
        }

        try {
            // Parse parameters
            int id = Integer.parseInt(idStr);
            double price = Double.parseDouble(priceStr);

            // Update product in DAO
            productDAO.Update(id, name, price);

            // Redirect to list page after successful update
            response.sendRedirect("list");

        } catch (NumberFormatException e) {
            // Handle if id or price is not a valid number
            response.getWriter().println("Invalid id or price format. Please enter valid numbers.");
        } catch (Exception e) {
            // Handle other exceptions
            throw new ServletException("Error updating product", e);
        }
    }
}
package Servlet;

import dao.StudentDAO;
import entiy.Student;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class zhuceServlet extends HttpServlet {
    public void service(HttpServletRequest request,
                        HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        String name = request.getParameter("name");
        String idname = request.getParameter("idname");
        String pd = request.getParameter("pd");
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out = response.getWriter();
        try {
            if (name == null || idname == null || pd == null ||
                    name.isEmpty() || idname.isEmpty() || pd.isEmpty()) {
                throw new IllegalArgumentException("参数不能为空");
            }

            StudentDAO dao = new StudentDAO();
            Student e1 = new Student();
            e1.setName(name);
            e1.setIdname(Integer.parseInt(idname));
            e1.setPd(pd);
            dao.save(e1);
            response.sendRedirect("denglu.jsp");
        } catch (NumberFormatException e) {
            out.println("ID必须是数字");
        } catch (IllegalArgumentException e) {
            out.println(e.getMessage());
        } catch (Exception e) {
            e.printStackTrace();
            out.println("系统繁忙,请稍后再试!");
        } finally {
            out.close();
        }
    }

}


util->DBUtil

package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBUtil {
    public static Connection getConnection() throws Exception {
        Connection conn = null;
        try {
            Class.forName("com.mysql.jdbc.Driver");
            conn = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/sdjyy?" +
                            "useUnicode=true&characterEncoding=utf8","root","asd123"
            );
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
        return conn;
    }
    public static void close(Connection conn){
        if(conn!=null){
            try {
                conn.close();
            }catch (SQLException e){
                e.printStackTrace();
            }
        }
    }
    public static void main(String[] args)throws Exception{
        Connection conn = getConnection();
        System.out.println(conn);
    }
}

 


web.xml 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">
    <servlet>
        <servlet-name>zhuce</servlet-name>
        <servlet-class>Servlet.zhuceServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>zhuce</servlet-name>
        <url-pattern>/zhuce</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Login</servlet-name>
        <servlet-class>Servlet.LoginServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Login</servlet-name>
        <url-pattern>/Login</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Shopping</servlet-name>
        <servlet-class>Servlet.ShoppingServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>Shopping</servlet-name>
        <url-pattern>/Shopping</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>list</servlet-name>
        <servlet-class>Servlet.listServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>list</servlet-name>
        <url-pattern>/list</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>add</servlet-name>
        <servlet-class>Servlet.AddShoppingServlet</servlet-class>
    </servlet>

    <servlet-mapping>
        <servlet-name>add</servlet-name>
        <url-pattern>/add</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>load</servlet-name>
        <servlet-class>Servlet.SelectShoppingServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>load</servlet-name>
        <url-pattern>/load</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>update</servlet-name>
        <servlet-class>Servlet.UpdateShoppingServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>update</servlet-name>
        <url-pattern>/update</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>total</servlet-name>
        <servlet-class>Servlet.TotalServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>total</servlet-name>
        <url-pattern>/total</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>LSQD</servlet-name>
        <servlet-class>Servlet.LSQDServlet</servlet-class>
    </servlet>
    <servlet-mapping>
        <servlet-name>LSQD</servlet-name>
        <url-pattern>/LSQD</url-pattern>
    </servlet-mapping>

</web-app>

JSP代码 

AddShopping.jsp

<%@page contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<%@page import="java.util.*,java.text.*,dao.*" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Add Product</title>
    <link rel="stylesheet" href="css/style.css">
    <style>
        /* 这里可以添加页面特定的 CSS 样式 */
        body {
            font-family: Arial, sans-serif;
            background-color: #f0f0f0;
            margin: 0;
            padding: 0;
        }
        #wrap {
            width: 80%;
            margin: 0 auto;
            background-color: #fff;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        header {
            background-color: #333;
            color: #fff;
            padding: 10px;
            text-align: center;
        }
        #content {
            padding: 20px;
        }
        .form_table {
            width: 100%;
        }
        .form_table td {
            padding: 10px;
        }
        .inputgri {
            width: 100%;
            padding: 8px;
            border: 1px solid #ccc;
            border-radius: 4px;
            box-sizing: border-box;
            font-size: 14px;
        }
        .button {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
        }
        .button:hover {
            background-color: #45a049;
        }
        #footer {
            background-color: #333;
            color: #fff;
            text-align: center;
            padding: 10px;
        }
    </style>
</head>
<body>
<div id="wrap">
    <div id="content">
        <h1>添加商品:</h1>
        <form action="add" method="post">
            <table class="form_table">
                <tr>
                    <td align="right">Name:</td>
                    <td><input type="text" class="inputgri" name="name" /></td>
                </tr>
                <tr>
                    <td align="right">Price:</td>
                    <td><input type="text" class="inputgri" name="price" /></td>
                </tr>
            </table>
            <p><input type="submit" class="button" value="确认添加"  /></p>
        </form>
    </div>
    <footer id="footer">
        sdjyw@126.com
    </footer>
</div>
</body>
</html>

 Checkoust.jsp

<%@ page import="entiy.Total" %>
<%@ page import="java.util.*" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@page contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<html>
<head>
    <title>Title</title>
    <style>
        .table {
            width: 100%;
            border-collapse: collapse;
        }
        .table_header {
            background-color: lightgray;
        }
        .table td, .table th {
            border: 1px solid black;
            padding: 8px;
        }
        .button {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            cursor: pointer;
        }
    </style>

</head>
<body>
<h1>
    查看您的历史清单
</h1>
<h2>
    <p>
        <%
            Date date = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        %>
        <%=sdf.format(date)%>
        <br />
    </p >
</h2>
<table class="table">
    <tr class="table_header">
        <td>
            ID
        </td>
        <td>
            消费金额
        </td>
    </tr>

    <%
        List<Total> totals = (List<Total>) request.getAttribute("total");
        if (totals != null && !totals.isEmpty()) {
            for (int i = 0; i < totals.size(); i++) {
                Total e = totals.get(i);
    %>
    <tr>
        <td><%= e.getId() %></td>
        <td><%= e.getTotal() %></td>
    </tr>
    <%
        }
    } else {
    %>
    <tr>
        <td colspan="2">没有找到消费金额记录。</td>
    </tr>
    <%
        }
    %>


</table>
<p>
    <input type="button" class="button" value="返回主页面" onclick="location='list'"/>
</p >
</div>
</div>
<div id="footer">
    <div id="footer_bg">
        sdjyy@444.com
    </div>
</div>
</div>
</body>
</html>

 denglu.jsp

<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8" %>
<%@page import="java.util.*,java.text.*,entiy.*" %>
<!DOCTYPE html>
<html>
<head>
    <title>交易网登录</title>
    <script>
        // 检查是否有错误信息参数,如果有则显示弹框提示
        <% if ("1".equals(request.getParameter("error"))) { %>
        window.onload = function() {
            alert("您的账号或密码输入错误,请重试。");
        }
        <% } %>
    </script>
    <style>
        h1{
            font-size: 40px;
            color: blanchedalmond;
            text-align: center;
            font-family: 'Courier New', Courier, monospace;
            font-style: italic;
        }
    </style>
</head>
<body>
<h1 name="top">交易网</h1>
<table align="center" cellspacing="0">
    <tr>
        <td>
            <table cellpadding="0">
                <tr>
                    <!-- 使用相对路径引用图片 -->
                    <td><img src="img/3.jpg"></td>
                </tr>
                <tr>
                    <td>
                        <ul>
                            <li>全面支持iPhone/iPad及Android等系统</li>
                            <li>客户端、手机与网页,实现发送、阅读邮件立即同步普通登录手机号登录</li>
                        </ul>
                    </td>
                </tr>
            </table>
        </td>
        <td>
            <table border="1" cellspacing="0">
                <form action="Login" method="post">
                    <tr>
                        <td>
                            <table cellpadding="30">
                                <tr>
                                    <td colspan="2" align="center"><strong>登录</strong></td>
                                </tr>
                                <tr>
                                    <td>昵称:
                                        <input type="text" id="name" name="name">
                                    </td>
                                </tr>
                                <tr>
                                    <td>账号:
                                        <input type="text" id="idname" name="idname">
                                    </td>
                                </tr>
                                <tr>
                                    <td>密码:
                                        <input type="password" id="pd" name="pd">
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="2">
                                        <input type="submit" value="登录" onclick="f1();" />
                                        <!-- 注册按钮改用正确的 <a> 标签 -->
                                        <a href="zhuce.jsp"><input type="button" value="注册" onclick="f2();"></a>
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </form>
            </table>
        </td>
    </tr>
    <tr>
        <td align="right">关于交易网</td>
    </tr>
</table>

</body>
</html>

 index.jsp

<%--
  Created by IntelliJ IDEA.
  User: NIL
  Date: 2024/7/17
  Time: 9:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
  </head>
  <body>
  $END$
  </body>
</html>

 shopping.jsp

<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="entiy.Product" %>
<%@ page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <title>购物车</title>
    <meta charset="utf-8"/>
    <style type="text/css">
        body {
            background-color: #f0f0f0; /* 设置整个页面的背景颜色 */
            background-image: url('img/f2.png'); /* 设置背景图片 */
            background-size: cover; /* 图片铺满整个页面 */
            background-repeat: no-repeat; /* 不重复显示背景图片 */
            background-attachment: fixed; /* 固定背景图片,不随页面滚动 */
            font-family: Arial, sans-serif; /* 设置页面字体 */
            margin: 0; /* 去除页面默认的边距 */
            padding: 0; /* 去除页面默认的内边距 */
        }
        h1 {
            text-align: center;
            margin-top: 20px;
            color: #555;
        }
        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
        }
        .user-info {
            text-align: right;
            margin-top: 10px;
            margin-right: 10px;
        }
        table {
            width: 100%;
            border: 1px solid #ddd;
            border-collapse: collapse;
            background-color: #fff;
            margin-top: 20px;
        }
        table th, table td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: center;
        }
        th {
            background-color: #f2f2f2;
        }
        td img {
            max-width: 50px;
            display: block;
            margin: 0 auto;
        }
        .button {
            padding: 12px 24px;
            font-size: 16px;
            background-color: #007bff;
            color: #fff;
            border: none;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        .button:hover {
            background-color: #0056b3;
        }
        .checkout {
            text-align: center;
            margin-top: 20px;
        }
        input[type="submit"] {
            padding: 14px 28px;
            font-size: 18px;
            background-color: #28a745;
            color: #fff;
            border: none;
            cursor: pointer;
            transition: background-color 0.3s;
        }
        input[type="submit"]:hover {
            background-color: #218838;
        }
    </style>
</head>
<body>
<h1>交易平台</h1>
<!-- 用户信息 -->
<div style="text-align: right; margin-top: 10px; margin-right: 10px;">
    <form action="Shopping" method="post">
        <input type="hidden" name="action" value="getUsername">
        <%
            String username = (String) session.getAttribute("username");
            if (username == null) {
                username = "游客";
            }
        %>
        <span>您好,<%= session.getAttribute("username") %></span>
        <span> | 现在时间:  <%
            Date date = new Date();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        %>
        <%=sdf.format(date )%>
        </span>
    </form>
</div>

<table>
    <tr>
        <th>商品</th>
        <th>单价(元)</th>
        <th>操作</th>
    </tr>
    <%
        List<Product> products = (List<Product>) request.getAttribute("goods");
        if (products == null) {
            System.out.println("Products list is null!");
            // 可以根据实际情况做进一步处理,如返回到上一页或者显示错误信息。
        } else {
            for (int i=0; i<products.size(); i++) {
                Product e = products.get(i);
    %>
    <tr>
        <td><%=e.getName()%></td>
        <td><%=e.getPrice()%></td>
        <td>
            <a href="load?id=<%=e.getId()%>">修改</a>
            <input type="button" value="加入购物车" onclick="add_shoppingcart(this);">
        </td>
    </tr>
    <%
            }
        }
    %>

</table>
<p>
    <input type="button" class="button" value="添加商品" onclick="location='AddShopping.jsp'"/>
</p>
<h1>购物车</h1>
<form action="total" method="post">
<table>
    <thead>
    <tr>
        <th>商品</th>
        <th>单价(元)</th>
        <th>数量</th>
        <th>金额(元)</th>
        <th>删除</th>
    </tr>
    </thead>
    <tbody id="goods">
    </tbody>
    <tfoot>
    <tr>
        <td colspan="3" align="right">总计</td>
        <td><input type="text" name="total" id="total" value="" /> </td>
        <td></td>
    </tr>
    </tfoot>
</table>
<!-- 去支付按钮 -->
<div style="text-align: center; margin-top: 20px;">
        <input type="submit" value="去支付" onclick="f1();" />
</div>
    </form>
<p>
   <input type="button"value="历史清单" onclick="location='LSQD'"/>
</p>
<script type="text/javascript">
   function f1(){
       alert("支付成功!");
   }
    function del(btn){
        //获取当前点击的删除按钮所在的tr
        var tr = btn.parentNode.parentNode;
        tr.parentNode.removeChild(tr);
        var tds = tr.getElementsByTagName("td");
        total();

    }
    function add(btn){
        var td = btn.parentNode;
        var inputs = td.getElementsByTagName("input");
        var text = inputs[1];
        var amount = parseInt(text.value)+1;
        text.value = amount;
        var tr = btn.parentNode.parentNode;
        var tds = tr.getElementsByTagName("td");
        var pr = parseFloat(tds[1].innerText);
        mny1 = pr*amount;
        //alert(mny1)
        tds[3].innerText = mny1;
        total();
    }
    function minu(btn){
        var td = btn.parentNode;
        var tr = td.parentNode;
        var inputs = td.getElementsByTagName("input");
        var text = inputs[1];
        if (text.value>1){
            var amount = parseInt(text.value)-1;
            text.value = amount;
            var tds = tr.getElementsByTagName("td");
            var pr = parseInt(tds[1].innerText);
            mny2 = pr*amount;
            tds[3].innerText = mny2;

        }else{
            tr.parentNode.removeChild(tr);
        }
        total();

    }
    function total(){
        //1.获取购物车中所有的商品行
        var tbody = document.getElementById("goods");
        var trs = tbody.getElementsByTagName("tr");
        //2.遍历这些行,获取每一行的金额
        var sum = 0;
        for(var i=0;i<trs.length;i++){
            var tr = trs[i];
            //取当前行的金额
            var tds = tr.getElementsByTagName("td");
            var mny = parseFloat(tds[3].innerText);
            sum = sum+mny;
        }
        document.getElementById("total").value=sum;

    }

    function add_shoppingcart(btn){
        var tbody = document.getElementById("goods");
        var tr = btn.parentNode.parentNode;
        var tds = tr.getElementsByTagName("td");
        var trs = tbody.getElementsByTagName("tr")
        var name = tds[0].innerText;
        var price = tds[1].innerText;
        for (var i=0;i<trs.length;i++) {
            var tr1 = trs[i];
            var tds1 = tr1.getElementsByTagName("td");
            var name1 = tds1[0].innerText;
        }

        if(name==name1) {
            var TD = tds1[2];
            var inputs = TD.getElementsByTagName("input");
            var text = inputs[1];
            var amount = parseInt(text.value) + 1;
            mny1 = pr * amount;
            tds1[3].innerText = mny1;
            total();
        }

        else {
            var ntr = tbody.insertRow();
            ntr.innerHTML =
                '<td>'+name+'</td>'+
                '<td>'+price+'</td>'+
                '<td align="center">'+
                '<input  type="button" value="-" onclick="minu(this);"/>'+
                '<input   type="text" size="3" readonly value="1"/>'+
                '<input  type="button" value="+" onclick="add(this);"/>'+
                '</td>'+
                '<td>'+price+'</td>'+
                '<td align="center"><input type="button" value="x" onclick="del(this);"/></td></tr>';

            total();}
    }
</script>
</body>
</html>

Update.jsp

<%@ page import="entiy.Product" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <title>修改商品信息</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" type="text/css"
          href="css/style.css" />
</head>

<body>
<div id="wrap">
    <div id="top_content">
        <div id="header">
            <div id="rightheader">
            </div>
            <div id="topheader">
                <h1 id="title">
                   商品修改
                </h1>
            </div>
            <div id="navigation">
            </div>
        </div>
        <div id="content">
            <p id="whereami">
            </p>
            <h1>
                修改商品信息:
            </h1>
            <form action="update" method="post">
                <%
                    Product product = (Product) request.getAttribute("goods");

                    System.out.println(product.getId());
                %>
                <table cellpadding="0" cellspacing="0" border="0"
                       class="form_table">

                    <tr>
                        <td valign="middle" align="right">
                            商品:
                        </td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" name="name" value="<%=product.getName()%>" />
                        </td>
                    </tr>
                    <tr>
                        <td valign="middle" align="right">
                            价格:
                        </td>
                        <td valign="middle" align="left">
                            <input type="text" class="inputgri" name="price" value="<%=product.getPrice()%>" />
                            <input type="hidden" name="id" value="<%=product.getId()%>">
                        </td>
                    </tr>

                </table>
                <p>
                    <input type="submit" class="button" value="提交" />
                </p>
            </form>
        </div>
    </div>
    <div id="footer">
        <div id="footer_bg">
            ABC@126.com
        </div>
    </div>
</div>
</body>
</html>

zhuce.jsp

<%@page contentType="text/html;charset=utf-8" pageEncoding="UTF-8" %>
<%@page import="java.util.*,java.text.*,entiy.*" %>
<!DOCTYPE html>
<html>
<head>
    <title>交易网注册</title>
    <script>
        function f2(){
            alert("确认注册?");
        }
    </script>
    <style>
        h1 {
            font-size: 40px;
            color: blanchedalmond;
            text-align: center;
            font-family: 'Courier New', Courier, monospace;
            font-style: italic;
        }
    </style>
</head>
<body>
<h1 name="top">交易网</h1>
<table align="center" cellspacing="0">
    <tr>
        <td>
            <table border="1" cellspacing="0">
                <form action="zhuce" method="post">
                    <tr>
                        <td>
                            <table cellpadding="30">
                                <tr>
                                    <td colspan="2" align="center"><strong>注册</strong></td>
                                </tr>
                                <tr>
                                    <td>昵称:
                                        <input type="text" id="name" name="name">
                                    </td>
                                </tr>
                                <tr>
                                    <td>帐号:
                                        <input type="text" id="idname" name="idname">(输入九位以内整数字)
                                    </td>
                                </tr>
                                <tr>
                                    <td>密码:
                                        <input type="password" id="pd" name="pd">
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" colspan="2">
                                        <input type="submit" value="注册" onclick="f2();">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </form>
            </table>
        </td>
    </tr>
    <tr>
        <td align="right">关于交易网</td>
    </tr>
</table>
</body>
</html>

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

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

相关文章

Comsol 声固耦合条件下超长水管路声传递损失

声固耦合条件指的是声波在固体和液体之间传递时&#xff0c;两者之间存在接触或耦合的情况。在水管路中&#xff0c;声固耦合条件下的声传递损失可以通过以下几个因素来影响和计算&#xff1a; 1. 声波的反射和透射&#xff1a;当声波从一个介质传递到另一个介质时&#xff0c…

服务器 Linux 的网络信息

博主上回大致讲解了文件系统&#xff0c;今天来说说 Linux 的网络信息&#xff0c;还是比较重要的~ 主机名称 临时修改 hostname node01 永久修改 vi /etc/hostname DNS解析 域名解析服务可以将域名转换为IP地址DNS域名劫持 window --> C:\Windows\System32\drivers…

Java 2.2 - Java 集合

Java 集合&#xff0c;也叫做容器&#xff0c;主要是由两大接口派生而来&#xff1a;一个是 Collection 接口&#xff0c;主要用于存放单一元素&#xff1b;另一个是 Map 接口&#xff0c;主要用于存放键值对。对于 Collection 接口&#xff0c;其下又有三个主要的子接口&#…

七大云安全威胁及其应对方法

关注公众号网络研究观获取更多内容。 对于任何依赖云来容纳快速增长的服务的企业来说&#xff0c;确保安全都是重中之重。然而&#xff0c;正如大多数云采用者很快意识到的那样&#xff0c;迁移到动态云环境需要新的和更新的安全措施&#xff0c;以确保数据和其他关键资产在整…

凯特王妃与戴安娜王妃:有跨越时空的优雅共鸣!

显而易见的是都是王妃,而王妃不仅是称谓也是一个头衔,她们同时要承担这个头衔应尽的职责! 在皇室世界里,总有一些名字,如同璀璨星辰,即便时光流转,依旧熠熠生辉。现在让我们揭开一段不为人知的幕后故事——凯特王妃与已故的戴安娜王妃之间,那些超越时代、共通的优雅与情…

前端模块化-手写mini-vite

前言 本文总结了一些关于 Vite 的工作原理&#xff0c;以及一些实现细节。 本节对应的 demo 可以在这里找到。 什么是 Vite Vite 是一个基于浏览器原生 ES imports 的开发服务器。利用浏览器去解析 imports&#xff0c;在服务器端按需编译返回&#xff0c;完全跳过了打包这个…

PyTorch深度学习实战(5)—— Tensor的命名张量和基本结构

1. 命名张量 命名张量&#xff08;Named Tensors&#xff09;允许用户将显式名称与Tensor的维度关联起来&#xff0c;便于对Tensor进行其他操作。笔者推荐使用维度的名称进行维度操作&#xff0c;这样可以避免重复计算Tensor每个维度的位置。支持命名张量的工厂函数&#xff08…

怎么删除iPhone重复照片:解放你的存储空间

在数字化时代&#xff0c;iPhone已成为我们记录生活点滴的重要工具。从家庭聚会的快乐时光到户外冒险的壮观景象&#xff0c;我们依靠iPhone捕捉无数珍贵瞬间。然而&#xff0c;这种便利性带来的一个副作用是&#xff0c;相册很快就会充满重复的照片&#xff0c;不仅占用了宝贵…

【IC设计】时序分析面试题总结(亚稳态、建立/保持裕量计算、最高时钟频率计算、时序违例解决办法)

文章目录 基本概念亚稳态建立时间和保持时间 常见问题1.为什么触发器要满足建立时间和保持时间&#xff1f;2.建立时间裕量和保持时间裕量的计算&#xff1f;3.最高时钟频率的计算&#xff1f;流水线思想&#xff1f;4.时序违例的解决办法&#xff1f; 基本概念 亚稳态 亚稳态…

简单的 CompletableFuture学习笔记

简单的 CompletableFuture学习笔记 这里记录一下自己学习的内容&#xff0c;简单记录一下方便后续学习&#xff0c;内容部分参考 CompletableFuture学习博客 1. CompletableFuture简介 在api接口调用时间过长&#xff0c;调用过多外围接口时&#xff0c;为了提升性能&#x…

Self-study Python Fish-C Note14 P50to51

函数 (part 4) 本节主要讲函数 递归 递归 (recursion) 递归就是函数调用自身的过程 示例1&#xff1a; def fun1(i):if i > 0: print(something)i-1fun1(i) fun1(5) # 这样就会打印五遍 somethingsomething something something something something要让递归正常工作&am…

IDEA2024.2重磅发布,更新完有4G!

JetBrains 今天宣布了其 IDE 家族版本之 2024.2 更新&#xff0c;其亮点是新 UI 现在已是默认设置&#xff0c;并且对 AI Assistant &#xff08;AI助手&#xff09;进行了几项改进。 安装密道 新 UI 的设计更加简约&#xff0c;可以根据需要以视觉方式扩展复杂功能。值得开发…

Arduino学习笔记2——初步认识Arduino程序

Arduino使用的编程语言是C。 一、注释文字 我们可以在程序中插入注释文字来提示开发者代码的作用。在Arduino中&#xff0c;单行注释用的是两个斜杠&#xff0c;多行注释用的是对称的斜杠加星号&#xff1a; 二、函数 和C语言相同&#xff0c;可以看到在打开IDE自动打开的默…

高并发下的分布式缓存 | Cache-Aside缓存模式

Cache-aside 模式的缓存操作 Cache-aside 模式&#xff0c;也叫旁路缓存模式&#xff0c;是一种常见的缓存使用方式。在这个模式下&#xff0c;应用程序可能同时需要同缓存和数据库进行数据交互&#xff0c;而缓存和数据库之间是没有直接联系的。这意味着&#xff0c;应用程序…

Java数据结构 | 二叉树基础及基本操作

二叉树 一、树型结构1.1 树的概念1.2 关于树的一些常用概念&#xff08;很重要&#xff01;&#xff01;&#xff01;&#xff09;1.3 树的表示形式1.4 树的应用 二、二叉树2.1 二叉树的概念2.2 两种特殊的二叉树2.3 二叉树的性质2.4 二叉树的存储2.5 二叉树的基本操作2.5.1 代…

【前端可视化】 大屏可视化项目二 scale适配方案 g6流程图 更复杂的图表

项目介绍 第二个大屏可视化&#xff0c;整个项目利用scale进行按比例适配。 图表更加复杂&#xff0c;涉及到图表的叠加&#xff0c;mark&#xff0c;地图&#xff0c;g6流程图的能等 始终保持比例适配(本项目方案),始终满屏适配(项目一). echarts绘制较为复杂图表&#xff0…

C++:string类(auto+范围for,typeid)

目录 前言 auto typeid 范围for 使用方法 string类的模拟实现 默认构造函数 拷贝构造函数 swap 赋值重载 析构函数 迭代器iterator begin和end c_str clear size capacity []运算符重载 push_back reserve append 运算符重载 insert erase find npos…

postgresql 宝塔 连接不上,prisma

不太熟悉pgsql; 配置搞了半天; 一直连不上远程数据库; 后台经过探索发现需要以下配置 1. 端口放行; 5422 (pgsql的端口) 2.编辑 pg_hba.conf 文件最后新增一条,这样可以外部使用postgres超级管理员账号 host all all 0.0.0.0/0 md5 3. pris…

数据结构复杂度

文章目录 一. 数据结构前言1.1 数据结构1.2 算法 二. 算法效率2.1 时间复杂度2.1.1 T(N)函数式2.1.2 大O的渐进表示法 一. 数据结构前言 1.1 数据结构 什么是数据结构呢&#xff1f;打开一个人的主页&#xff0c;有很多视频&#xff0c;这是数据&#xff08;杂乱无章&#xf…

了解k8s架构,搭建k8s集群

kubernetes 概述 Kubernetes 集群图例 安装控制节点 安装网络插件 安装 calico 安装计算节点 2、node 安装 查看集群状态 kubectl get nodes # 验证容器工作状态 [rootmaster ~]# kubectl -n kube-system get pods