【JavaWeb程序設計】JSP實現購物車功能

目錄

一、結合之前所學的相關技術,編寫代碼實現以下購物車功能

1. 我實現的功能運行截圖如下

(1)商品列表頁面home.jsp

?(2)登錄賬號頁面/未登錄點擊結賬頁面

(3)重新登錄頁面(記住上次登錄的用戶名和密碼)

(4)點擊任意商品加入購物車之后查看購物車

2. 數據庫test存放的表格

(1)user表

(2)product表

3. 實體類

(1)User

(2)Product.java

4. CartController.java

5. JSP頁面

(1)展現商品列表(home.jsp)

(2)登陸頁面(login.jsp)

(3)登錄后臺處理頁面(loginAction.jsp)

(4)結賬頁面(checkout.jsp)

(5)購物車頁面(cart.jsp)


一、結合之前所學的相關技術,編寫代碼實現以下購物車功能

1. 編寫一個頁面,展現商品列表(靜態頁面),頁面右上方有登陸、結賬和查看購物車三個按鈕,下方展示網站歷史訪問的人數

2. 用戶點擊商品后,可以將商品加入購物車

3. 用戶點擊登陸,跳轉到登陸頁面

4. 用戶點擊結賬,若已登陸跳轉至結賬頁面,否則跳轉到登陸頁面登陸后再跳轉到結賬頁。

5. 用戶點擊查看購物車按鈕,跳轉至購物車頁面,可查看購物車列表、增加商品數量或者刪除商品

1. 我實現的功能運行截圖如下

(1)商品列表頁面home.jsp

?(2)登錄賬號頁面/未登錄點擊結賬頁面

(3)重新登錄頁面(記住上次登錄的用戶名和密碼)

(4)點擊任意商品加入購物車之后查看購物車

?(5)增加或減少商品

(6)商品數量減為0時移除

(7)點擊去結算,展示總金額

2. 數據庫test存放的表格

(1)user表

(2)product表

導入jar包?

3. 實體類

(1)User

package com.ryx.web.sy7;import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;@NoArgsConstructor
@AllArgsConstructor
@Data
@Builder
public class User {private String username;private String password;
}

(2)Product.java

package com.ryx.web.sy7;import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;import java.math.BigDecimal;@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Product {Integer id;String name;String imagePath;BigDecimal price;String description;
}

(3)ProductVo

package com.ryx.web.sy7;import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;public class ProductVo extends Product {@Getter@SetterInteger count; //統計數量public ProductVo(Integer id, Integer count, String name, double price, String imagePath) {super();this.id = id;this.count = count;this.name = name;this.price = BigDecimal.valueOf(price);this.imagePath=imagePath;}
}

4. CartController.java

package com.ryx.web.sy7;import lombok.SneakyThrows;
import org.springframework.util.ObjectUtils;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.*;
import java.util.HashMap;
import java.util.Map;@WebServlet(name = "shoppingCart", value = "/shoppingCart")
public class CartController extends HttpServlet {
// ???連接數據庫private static final String DB_URL = "jdbc:mysql://localhost:3306/test";private static final String DB_USERNAME = "root";private static final String DB_PASSWORD = "abc1234";@SneakyThrowsprotected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {Integer id = Integer.valueOf(request.getParameter("id"));String op = request.getParameter("op");String whereCome = request.getHeader("Referer");String redirectPath = null;
// ???????如果在主頁點擊加入購物車超鏈接,不跳轉if (whereCome.equals("http://localhost:8080/sy7/home.jsp")) {redirectPath = request.getContextPath() + "/sy7/home.jsp";} else {
// ???????????如果在購物車頁面增加或刪除商品也不跳轉redirectPath = request.getContextPath() + "/sy7/cart.jsp";}HttpSession session = request.getSession();Map<Integer, ProductVo> cart = (Map<Integer, ProductVo>) session.getAttribute("cart");if (ObjectUtils.isEmpty(cart)) {cart = new HashMap();}switch (op) {
// ???????????添加商品case "add":if (!ObjectUtils.isEmpty(cart.get(id))) {ProductVo productVo = cart.get(id);productVo.setCount(productVo.getCount() + 1);cart.put(id, productVo);} else {Class.forName("com.mysql.jdbc.Driver");try (Connection conn = DriverManager.getConnection(DB_URL, DB_USERNAME, DB_PASSWORD)) {String query = "SELECT * FROM product WHERE id = ?";try (PreparedStatement stmt = conn.prepareStatement(query)) {stmt.setInt(1, id);try (ResultSet rs = stmt.executeQuery()) {if (rs.next()) {String name = rs.getString("name");double price = rs.getDouble("price");String imagePath = rs.getString("image_path");Integer iid = rs.getInt("id");ProductVo productVo = new ProductVo(iid, 1, name, price, imagePath);cart.put(id, productVo);}}}} catch (SQLException e) {e.printStackTrace();}}break;
// ?????????減少商品case "sub":if (!ObjectUtils.isEmpty(cart.get(id))) {ProductVo productVo = cart.get(id);
// ???????????????????防止出現負數if (productVo.getCount() > 1) {productVo.setCount(productVo.getCount() - 1);cart.put(id, productVo);} else {
// ???????????????????????如果小于1則移除商品cart.remove(id);}}break;}session.setAttribute("cart", cart);response.sendRedirect(redirectPath);}
}

5. JSP頁面

(1)展現商品列表(home.jsp)

CSS

table {border-collapse: collapse;width: 86%;
}table, th, td {border: 1px solid gainsboro;
}td {width: 200px;
}.redText {color: #FF0000;
}.pinkTest {color: lightpink;
}
<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %>
<%--Created by IntelliJ IDEA.User: 86189Date: 2023/10/23主頁面展示商品
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>小煊的美妝鋪</title></head>
<body>
<h1 align="center" class="pinkTest">歡迎來到小煊的美妝鋪~</h1>
<div align="right" style="width: 90%"><a href="login.jsp">登錄</a></div>
<div align="right" style="width: 90%"><a href="checkout.jsp">結算</a></div>
<div align="right" style="width: 90%"><a href="cart.jsp">查看購物車</a></div>
<br><table align="center"><%---------------------- 獲取商品數據?-----------------------------%><%Connection conn = null;PreparedStatement stmt = null;ResultSet rs = null;try {//連接數據庫Class.forName("com.mysql.cj.jdbc.Driver");conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "abc1234");String query = "SELECT * FROM product";stmt = conn.prepareStatement(query);rs = stmt.executeQuery();int count = 0;while (rs.next()) {int id = rs.getInt("id"); //商品編號String name = rs.getString("name"); //商品名double price = rs.getDouble("price"); //價格String description = rs.getString("description"); //描述String imagePath = rs.getString("image_path"); // 圖片路徑//五個商品即換行if (count % 5 == 0) {out.println("<tr>");}%><td><br><%--------------------------圖片-----------------------%><div align="center"><img src="<%=request.getContextPath()+imagePath%>" width="180px" height="240px"></div><%--------------------------商品描述-----------------------%><div> <%=name%><%=description%>?</div><%--------------------------價格-----------------------%><div class="redText" align="left"> ¥:<%=price%>?</div><%--------------------------加購-----------------------%><div align="right"><form action="home.jsp" method="post"><button onclick="void(0)"><a style="text-decoration: none"href="<%=request.getContextPath()+"/shoppingCart?id="+id+"&op=add"%>"/>加入購物車</button></form></div></td><%//閉合標簽if (count % 5 == 4) {out.println("</tr>");}count++;}//最后不足五個,自動閉合if (count % 5 != 0) {out.println("</tr>");}} catch (Exception e) {e.printStackTrace();} finally {try {rs.close();} catch (Exception e) {}try {stmt.close();} catch (Exception e) {}try {conn.close();} catch (Exception e) {}}%>
</table>
<br>
<%
// ???初始化歷史訪問人數Integer accessCount = (Integer) session.getAttribute("accessCount");if (accessCount == null) {accessCount = new Integer(0);} else {accessCount = new Integer(accessCount.intValue() + 1);}session.setAttribute("accessCount", accessCount);
%><div>歷史訪問人數:<%= accessCount %>?</div>
</body>
</html>

(2)登陸頁面(login.jsp)

JSP程序段+JS代碼

<%-----------------------JSP程序段---------------------------%>
<%request.setCharacterEncoding("UTF-8");//一次性登錄String msg = request.getParameter("msg");
%>
<%if (msg != null) {String errorMessage = "賬號或密碼有誤,請重新輸入!";
%>
<script>var error = '<%= errorMessage %>';alert(error);
</script>
<%}
%><%-- 讀取Cookie --%>
<%Cookie[] cookies = request.getCookies();String savedUsername = null;String savedPassword = null;if (cookies != null) {for (Cookie cookie : cookies) {if (cookie.getName().equals("username")) {savedUsername = cookie.getValue();} else if (cookie.getName().equals("password")) {savedPassword = cookie.getValue();}}}
%>

HTML

<%--Created by IntelliJ IDEA.User: 86189Date: 2023/10/13登錄頁面
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head><style>body {display: flex;justify-content: center;padding-top: 40px;}.titlecolor{color: lightpink;}</style><title>登錄頁面</title>
</head>
<body>
<%-----------------------登錄表單--------------------------%>
<form action="loginAction.jsp" method="post"><h1 align="center" class="titlecolor">登錄賬號</h1><br><table width="300px"><tr><td><laber for="username">用戶名:</laber></td><td><input type="text" value="<%= savedUsername==null?"":savedUsername%>" id="username" name="username" required></td></tr><tr><td><label for="password">密碼:</label></td><td><input type="password" value="<%= savedPassword==null?"":savedPassword%>" id="password" name="password" required></td><td align="right"><input type="submit" value="登錄"></td></tr><tr><td></td><td><input type="checkbox" name="remember" value="member">記住密碼</td></tr></table>
</form></body>
</html>

(3)登錄后臺處理頁面(loginAction.jsp)

<%@ page import="com.ryx.web.sy7.User" %>
<%@ page import="java.sql.*" %>
<%--Created by IntelliJ IDEA.User: 86189Date: 2023/10/13判斷輸入的用戶信息是否存在數據庫
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %><%!public boolean validateUser(String username, String password) {// 使用JDBC連接數據庫Connection connection = null;PreparedStatement statement = null;ResultSet resultSet = null;String driver = "com.mysql.cj.jdbc.Driver";String url = "jdbc:mysql://localhost:3306/test"; ?//數據庫String user = "root"; //賬戶String psword = "abc1234"; //密碼try {try {try {Class.forName(driver);} catch (ClassNotFoundException e) {throw new RuntimeException(e);}// 獲取數據庫連接connection = DriverManager.getConnection(url, user, psword);} catch (SQLException e) {e.printStackTrace();}try {// 構造查詢語句String query = "SELECT * FROM test.user WHERE username = ?? ";// 創建PreparedStatement對象,并設置參數statement = connection.prepareStatement(query);statement.setString(1, username);// 執行查詢resultSet = statement.executeQuery();// 驗證用戶名和密碼if (resultSet.next()) {String storedPassword = resultSet.getString("password");if (storedPassword.equals(password)) {return true;}}} catch (SQLException e) {e.printStackTrace();}} finally {// 關閉連接和釋放資源try {if (resultSet != null) {resultSet.close();}if (statement != null) {statement.close();}if (connection != null) {connection.close();}} catch (SQLException e) {e.printStackTrace();}}return false;}%><%request.setCharacterEncoding("UTF-8");String username = request.getParameter("username");String password = request.getParameter("password");boolean isValidUser = validateUser(username, password);//驗證成功if (isValidUser) {// 創建形?Builder 構造者模式,鏈式編程User user = User.builder().username(username).password(password).build();String remember = request.getParameter("remember");if (remember != null && remember.equals("member")) {// 創建存儲用戶名和密碼的Cookie對象Cookie usernameCookie = new Cookie("username", username);Cookie passwordCookie = new Cookie("password", password);// 設置Cookie的有效期(設置為7天)usernameCookie.setMaxAge(7 * 24 * 60 * 60); // 7天passwordCookie.setMaxAge(7 * 24 * 60 * 60); // 7天// 將Cookie添加到響應中response.addCookie(usernameCookie);response.addCookie(passwordCookie);} else {// 刪除之前保存的CookieCookie[] cookies = request.getCookies();if (cookies != null) {for (Cookie cookie : cookies) {if (cookie.getName().equals("username") || cookie.getName().equals("password")) {cookie.setMaxAge(0); // 設置有效期為0,即立即刪除response.addCookie(cookie);}}}}session.setAttribute("user", user);//跳轉到其他頁面response.sendRedirect("home.jsp");} else {//驗證失敗,提示出錯response.sendRedirect("login.jsp?msg=failed");}%>

(4)結賬頁面(checkout.jsp)

HTML+JSP+JSTL

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.ryx.web.sy7.User" %>
<%@ page import="java.util.Map" %>
<%--Created by IntelliJ IDEA.User: 86189Date: 2023/10/21結算頁面
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<%--------------------判斷用戶是否登錄-----------------------%>
<%//存儲變量User user = (User) session.getAttribute("user");// ???未登錄用戶跳轉到登錄頁面if (user == null) {response.sendRedirect("login.jsp");}
%>
<head><meta charset="UTF-8"><title>結算</title>
</head>
<body>
<%----------------- 獲取購物車中的商品?------------------------%>
<h1 align="center" style="color: lightpink">訂單信息</h1>
<%session = request.getSession();Map<Integer, Integer> cart = (Map<Integer, Integer>) session.getAttribute("cart");if (cart == null) {out.println("購物車為空");return;}
%>
<%--計算總價錢--%>
<c:set var="totalAmount" value="0"/>
<c:forEach var="entry" items="${cart.entrySet()}"><c:set var="product" value="${entry.value}"/><%--單個商品的總額--%><c:set var="amount" value="${product.price * product.count}"/><%--所有商品的總額--%><c:set var="totalAmount" value="${totalAmount + amount}"/>
</c:forEach>
<div align="center"><h2>您應支付:¥${totalAmount}</h2><form action="checkout.jsp" method="POST"><input type="submit" value="確認訂單"></form>
</div></body>
</html>

(5)購物車頁面(cart.jsp)

CSS


table {border-collapse: collapse;
}table, th, td {border: 1px solid gainsboro;
}.titleTest {color: lightpink;
}td {width: 20%;
}a {text-decoration: none;
}

HTML

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%--Created by IntelliJ IDEA.User: 86189Date: 2023/10/21購物車頁面
--%>
<!DOCTYPE html>
<html>
<head><meta charset="UTF-8"><title>購物車</title></head>
<body>
<h1 align="center" class="titleTest">我的購物車</h1>
<c:if test="${cart!=null && cart.size()>0}"><table style="width: 1000px" align="center"><tr><th>商品信息</th><th>單價</th><th>數量</th><th>金額</th></tr><c:forEach var="entry" items="${cart.entrySet()}"><tr><c:set var="product" value="${entry.value}"/><%----------------------商品信息--------------------%><td><img src="${request.contextPath}${product.imagePath}" width="60px" height="80px">${product.name}</td><%----------------------單價--------------------%><td align="center">¥:${product.price}</td><%----------------------數量-/+--------------------%><td align="center"><button onclick="void(0)"><a href="<%=request.getContextPath()+"/shoppingCart?op=sub&id="%>${product.id}"/>-</button>${product.count}<button onclick="void(0)"><a href="<%=request.getContextPath()+"/shoppingCart?op=add&id="%>${product.id}"/>+</button></td><%----------------------金額--------------------%><td align="center">¥:${product.count*product.price}</td></tr></c:forEach></table>
</c:if><br><br>
<div style="width: 90%" align="right"><a href="home.jsp">繼續購物</a><a href="checkout.jsp">去結算</a></div>
</body>
</html>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/42214.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/42214.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/42214.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

昇思25天學習打卡營第18天|ShuffleNet圖像分類

一、簡介&#xff1a; ShuffleNetV1是曠視科技提出的一種計算高效的CNN模型&#xff0c;和MobileNet, SqueezeNet等一樣主要應用在移動端&#xff0c;所以模型的設計目標就是利用有限的計算資源來達到最好的模型精度。ShuffleNetV1的設計核心是引入了兩種操作&#xff1a;Poin…

如何在centos7安裝Docker

在centOS7中我們可以使用火山引擎鏡像源鏡像安裝Docker,以下是具體的安裝步驟。 step 1: 安裝必要的一些系統工具 sudo yum install -y yum-utils Step 2: 添加軟件源信息 sudo yum-config-manager --add-repo https://mirrors.ivolces.com/docker/linux/centos/docker-ce.r…

力扣雙指針算法題目:二叉樹的層序遍歷(BFS)

目錄 1.題目 2.思路解析 3.代碼 1.題目 . - 力扣&#xff08;LeetCode&#xff09; 2.思路解析 對二叉樹進行層序遍歷&#xff0c;顧名思義&#xff0c;就是按每一層的順序對二叉樹一層一層地進行遍歷 思路如下 從第一層開始&#xff0c;先將二叉樹地頭放入隊列q&#xff0…

獨孤思維:副業被罵煞筆,割韭菜

做副業不要被外界干擾&#xff0c;不要被情緒牽絆。 不要因為別人的無心謾罵&#xff0c;隨口一評&#xff0c;就偃旗息鼓。 不要因為自己的情緒需要&#xff0c;找存在感&#xff0c;尋求人安慰。 他強任他強&#xff0c;清風拂山崗。 他橫由他橫&#xff0c;明月照大江。…

2007-2022年中國各企業數字化轉型與供應鏈效率

企業數字化轉型與供應鏈效率是現代企業管理和發展的兩個關鍵方面。以下是對中國各企業數字化轉型與供應鏈效率數據的介紹&#xff1a; 數據簡介 企業數字化轉型&#xff1a;指企業通過采用數字技術與創新方法&#xff0c;改造業務流程、組織結構和產品服務&#xff0c;以提升…

UCOS-III 系統移植

1. 移植前準備 1.1 源碼下載 UCOS-III Kernel Source&#xff1a; https://github.com/weston-embedded/uC-OS3.git Micriμm CPU Source &#xff1a; https://github.com/weston-embedded/uC-CPU.git Micriμm Lib Source&#xff1a; https://github.com/weston-embedded…

Nginx配置文件全解:從入門到設計

Nginx配置文件全解&#xff1a;從入門到架構設計 1. Nginx配置文件基礎 Nginx的主配置文件通常位于/etc/nginx/nginx.conf?。配置文件使用簡單的文本格式&#xff0c;由指令和指令塊組成。 1.1 基本語法規則 每個指令以分號(;)結束指令塊用大括號({})包圍配置文件支持使用…

多方SQL計算場景下,如何達成雙方共識,確認多方計算作業的安全性

安全多方計算在SQL場景下的限制 隨著MPC、隱私計算等概念的流行&#xff0c; 諸多政府機構、金融企業開始考慮參與到多方計算的場景中&#xff0c; 擴展數據的應用價值。 以下面這個場景為例&#xff0c; 銀行可能希望獲取水電局和稅務局的數據&#xff0c;來綜合計算得到各…

DolphinScheduler-3.1.9 資源中心實踐

前言 目前DolphinScheduler最新的穩定版本是 3.1.9 &#xff0c;基于此做些探索&#xff0c;逐漸深化學習路徑&#xff0c;以便于加深理解。 3.2.1 是最新的版本。目前的穩定版本是 3.1.9 基礎環境&#xff1a;Hadoop3.3, Java 8, Python3, MacOS14.2.1 一、本地偽分布式安裝…

學習筆記——動態路由——IS-IS中間系統到中間系統(開銷)

四、IS-IS開銷 1、IS-IS 開銷簡介 在IS-IS協議剛面世時&#xff0c;互聯網網絡結構還非常簡單&#xff0c;因此IS-IS早期的版本中只使用了6bit來描述鏈路開銷&#xff0c;鏈路開銷的取值范圍是1-63。一條路由的開銷范圍只有10bit&#xff0c;取值范圍是0-1023。 隨著計…

前端實現無縫自動滾動動畫

1. 前言: 前端使用HTMLCSS實現一個無縫滾動的列表效果 示例圖: 2. 源碼 html部分源碼: <!--* Author: wangZhiyu <w3209605851163.com>* Date: 2024-07-05 23:33:20* LastEditTime: 2024-07-05 23:49:09* LastEditors: wangZhiyu <w3209605851163.com>* File…

【ubuntu】安裝(升級)顯卡驅動,黑屏|雙屏無法使用問題解決方法

every blog every motto: You can do more than you think. https://blog.csdn.net/weixin_39190382?typeblog 0. 前言 ubuntu 安裝(升級)顯卡驅動&#xff0c;黑屏|雙屏無法使用問題解決方法 由于項目需要&#xff0c;對顯卡驅動進行升級。升級完就黑屏。。。。&#xff0…

Fast R-CNN(論文閱讀)

論文名&#xff1a;Fast R-CNN 論文作者&#xff1a;Ross Girshick 期刊/會議名&#xff1a;ICCV 2015 發表時間&#xff1a;2015-9 ?論文地址&#xff1a;https://arxiv.org/pdf/1504.08083 源碼&#xff1a;https://github.com/rbgirshick/fast-rcnn 摘要 這篇論文提出了一…

WordPress禁止用戶注冊某些用戶名

不管在任何網站&#xff0c;用戶注冊時都有一個屏蔽非法關鍵詞&#xff0c;就是禁止注冊某些用戶名&#xff0c;原因是因為防止用戶使用一些特定的用戶名&#xff0c;例如管理員、官方等用戶名&#xff0c;還有就是那些攻擊性的詞語了。 加網站添加了屏蔽非法關鍵詞&#xff0…

BAT-致敬精簡

什么是bat bat是windows的批處理程序&#xff0c;可以批量完成一些操作&#xff0c;方便快速。 往往我們可以出通過 winR鍵來打開指令窗口&#xff0c;這里輸入的就是bat指令 這里就是bat界面 節約時間就是珍愛生命--你能想象以下2分鐘的操作&#xff0c;bat只需要1秒鐘 我…

考慮數據庫粒度的設計-提升效率

目錄 概要 場景 設計思路 小結 概要 公開的資料顯示&#xff0c;數據庫粒度是&#xff1a;“在數據庫領域&#xff0c;特別是數據倉庫的設計中&#xff0c;粒度是一個核心概念&#xff0c;它直接影響到數據分析的準確性和存儲效率。粒度的設定涉及到數據的詳細程度和精度&…

【JVM基礎篇】Java的四種垃圾回收算法介紹

文章目錄 垃圾回收算法垃圾回收算法的歷史和分類垃圾回收算法的評價標準標記清除算法優缺點 復制算法優缺點 標記整理算法&#xff08;標記壓縮算法&#xff09;優缺點 分代垃圾回收算法&#xff08;常用&#xff09;JVM參數設置使用Arthas查看內存分區垃圾回收執行流程分代GC算…

【SpringBoot】IDEA查看spring bean的依賴關系

前因&#xff1a;在研究springcloud config組件時&#xff0c;我發現config-server包下的EnvironmentController可以響應客戶端的請求&#xff0c;但EnvironmentController并不在啟動類所在的包路徑下&#xff0c;所以我推測它是作為某個Bean方法在生效&#xff0c;尋找bean的依…

vue-router 源碼分析——9.別名

這是對vue-router 3 版本的源碼分析。 本次分析會按以下方法進行&#xff1a; 按官網的使用文檔順序&#xff0c;圍繞著某一功能點進行分析。這樣不僅能學習優秀的項目源碼&#xff0c;更能加深對項目的某個功能是如何實現的理解。這個對自己的技能提升&#xff0c;甚至面試時…

DAY1: 實習前期準備

文章目錄 VS Code安裝的插件C/CCMakeGitHub CopilotRemote-SSH收獲 VS Code 下載鏈接&#xff1a;https://code.visualstudio.com 安裝的插件 C/C 是什么&#xff1a;C/C IntelliSense, debugging, and code browsing. 為什么&#xff1a;初步了解如何在VS Code里使用C輸出…