練習javaweb+mysql+jsp

只是簡單的使用mysql、簡單的練習。
有很多待完善的地方,比如list的servlet頁面,應該判斷有沒有用戶的。
比如list.jsp 應該循環list而不是寫死
index.jsp 樣式可以再優化一下的。比如按鈕就特丑。

本文展示了一個簡單的MySQL數據庫操作練習項目,主要包含以下內容:

數據庫連接工具類(BaseDao):
提供連接MySQL數據庫的基本功能
實現SQL執行(增刪改查)和資源關閉方法
使用JDBC驅動和預處理語句
用戶實體類(User):
包含id、用戶名、密碼等基本屬性
DAO層接口及實現:
定義用戶登錄、查詢、增刪改等操作
實現具體SQL執行和結果集處理
包含UserList(登錄驗證)、ALLUser(查詢所有)、addUser(添加用戶)等方法
項目目前存在以下待改進點:

前端頁面需要優化樣式
列表頁面應實現動態循環而非硬編碼
需要增加用戶存在性判斷等邏輯驗證
代碼結構有待完善
這是一個基礎的JDBC實踐項目,展示了數據庫連接、CRUD操作的基本實現方式。

連接后端
package com.zhang.dao;import java.sql.*;//連接數據庫工具
public class BaseDao {private String url = "jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8";private String username = "root";private String password = "1234";private static String driver = "com.mysql.jdbc.Driver";private Connection conn;private PreparedStatement ps;private ResultSet rs;static {try {//加載驅動Class.forName(driver);} catch (ClassNotFoundException e) {e.printStackTrace();}}//創建鏈接private void getConnection() {try {conn = DriverManager.getConnection(url, username, password);} catch (SQLException e) {e.printStackTrace();}}//執行sql//增刪改public int executeUpdate(String sql, Object... objs) {//獲得連接getConnection();try {
//select * from user where username=?and password=?ps = conn.prepareStatement(sql);if (objs != null) {for (int i = 0; i < objs.length; i++) {ps.setObject(i + 1, objs[i]);}}int i = ps.executeUpdate();close();//關閉資源return i;} catch (SQLException e) {e.printStackTrace();}return -1;}//查詢public ResultSet executeQuery(String sql,Object... objs) {getConnection();try {ps = conn.prepareStatement(sql);if (objs != null) {for (int i = 0; i < objs.length; i++) {ps.setObject(i + 1, objs[i]);}}rs = ps.executeQuery();return rs;} catch (SQLException e) {e.printStackTrace();}return null;}//關閉public void close() {try {if (rs != null) {rs.close();}if (ps != null) {ps.close();}if (conn != null) {conn.close();}} catch (SQLException e) {System.out.println("關閉出錯");}}public void test() {try {Class.forName(driver);Connection connection = DriverManager.getConnection(url, username, password);System.out.println("連接成功");} catch (ClassNotFoundException e) {e.printStackTrace();} catch (SQLException e) {e.printStackTrace();}}public static void main(String[] args) {BaseDao BaseDao = new BaseDao();BaseDao.test();}
}
實體類
public class User {private Integer id;private String username;private String password;private String name;private String addr;private String tel;
}
dao層

import com.zhang.entity.User;import java.util.List;public interface UserDao {//用戶登錄,新增用戶,刪除用戶,修改用戶。//用戶登錄User UserList(User user);//查詢所有List<User> ALLUser();//增加用戶信息int addUser(User user);//刪除用戶int delUserByID(Integer id);//修改用戶int updUserByID(Integer id);
}import com.zhang.dao.BaseDao;
import com.zhang.dao.UserDao;
import com.zhang.entity.User;import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;public class UserDaoImpl extends BaseDao implements UserDao {@Overridepublic User UserList(User user) {String sql = "select * from user where username= ? and password=?";ResultSet rs = executeQuery(sql,user.getUsername(),user.getPassword());try {User user1=null;if (rs.next()){user1= new User(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6));}close();return user1;} catch (SQLException e) {e.printStackTrace();}return null;}@Overridepublic List<User> ALLUser() {String sql = "select * from user";ResultSet rs = executeQuery(sql);List list=new ArrayList();try {while (rs.next()){list.add(new User(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6)));}close();} catch (SQLException e) {e.printStackTrace();}return list;}@Overridepublic int addUser(User user) {String sql = " insert into user(id,username,password,name,addr,tel) values(?,?,?,?,?,?);";int i = this.executeUpdate(sql,user.getId(),user.getUsername(),user.getPassword(),user.getName(),user.getAddr(),user.getTel());return i ;}@Overridepublic int delUserByID(Integer id) {return 0;}@Overridepublic int updUserByID(Integer id) {return 0;}public static void main(String[] args) {
//        UserDaoImpl UserDaoImpl=new UserDaoImpl();
////        System.out.println(UserDaoImpl.ALLUser());
//        List<User> users = UserDaoImpl.ALLUser();}}
service層
import com.zhang.entity.User;import java.util.List;public interface UserService {User UserList(User user);//增加用戶信息boolean addUser(User user);//刪除用戶boolean delUserByID(Integer id);//修改用戶boolean updUserByID(Integer id);//查詢所有List<User> ALLUser();
}import com.zhang.dao.UserDao;
import com.zhang.dao.impl.UserDaoImpl;
import com.zhang.entity.User;
import com.zhang.service.UserService;import java.util.List;public class UserServceImpl implements UserService {UserDao userDao=new UserDaoImpl();@Overridepublic User UserList(User user) {return userDao.UserList(user);}@Overridepublic boolean addUser(User user) {return userDao.addUser(user)>0?true:false;}@Overridepublic boolean delUserByID(Integer id) {return false;}@Overridepublic boolean updUserByID(Integer id) {return false;}@Overridepublic List<User> ALLUser() {return userDao.ALLUser();}
}
servlet層
import com.zhang.entity.User;
import com.zhang.service.UserService;
import com.zhang.service.impl.UserServceImpl;import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;@WebServlet("/addServlet")
public class AddServlet extends HttpServlet {UserService userService=new UserServceImpl();protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String username = request.getParameter("username");String password = request.getParameter("password");String name = request.getParameter("name");String addr = request.getParameter("addr");String tel = request.getParameter("tel");boolean b = userService.addUser(new User(null, username, password, name, addr, tel));response.sendRedirect("./list.jsp");}protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}
}import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;@WebServlet("/listServlet")
public class ListServlet extends HttpServlet {protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {System.out.println(123);response.sendRedirect("./list.jsp");}protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}
}import com.zhang.entity.User;
import com.zhang.service.UserService;
import com.zhang.service.impl.UserServceImpl;import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;@WebServlet("/loginServlet")
public class LoginServlet extends HttpServlet {UserService userService=new UserServceImpl();protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String username = request.getParameter("username");String password = request.getParameter("password");System.out.println(username+password);User user = userService.UserList(new User(username,password));List<User> list = userService.ALLUser();if(user!=null){//登陸成功request.getSession().setAttribute("user",user);request.getSession().setAttribute("list",list);response.sendRedirect("./list.jsp");}else {response.sendRedirect("./err.jsp");}}protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {}
}
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">
</web-app>

前端頁面

<!-- add.jsp --><%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>添加</title>
</head>
<body>
<form action="./addServlet" method="post"><input type="text" name="id" hidden><br>username:<input type="text" name="username"><br>password:<input type="text" name="password"><br>name:<input type="text" name="name"><br>addr:<input type="text" name="addr"><br>tel:<input type="text" name="tel"><br><input type="submit" value="提交">
</form>
</body>
</html><!-- err.jsp -->
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head><title>Title</title>
</head>
<body>
<h1>錯誤</h1>
</body>
</html><!-- index.jsp -->
<%@ page contentType="text/html;charset=UTF-8" language="java" %><html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Brook系統</title><script type="text/javascript" src="js/jquery-3.4.1.min.js"></script><style type="text/css">body {background-color:#00b38a;text-align:center;}.lp-login {position:absolute;width:500px;height:300px;top:50%;left:50%;margin-top:-250px;margin-left:-250px;background: #fff;border-radius: 4px;box-shadow: 0 0 10px #12a591;padding: 57px 50px 35px;box-sizing: border-box}.lp-login .loginBtn {display:block;text-decoration:none;height: 48px;width: 150px;line-height: 48px;font-size: 16px;color: #fff;text-align: center;background-image: -webkit-gradient(linear, left top, right top, from(#09cb9d), to(#02b389));background-image: linear-gradient(90deg, #09cb9d, #02b389);border-radius: 3px}input[type='text'] {height:30px;width:250px;}span {font-style: normal;font-variant-ligatures: normal;font-variant-caps: normal;font-variant-numeric: normal;font-variant-east-asian: normal;font-weight: normal;font-stretch: normal;font-size: 14px;line-height: 22px;font-family: "Hiragino Sans GB", "Microsoft Yahei", SimSun, Arial, "Helvetica Neue", Helvetica;}</style><script type="text/javascript">$(function(){$(".loginBtn").bind("click",function(){let username = $("#username").val();let password = $("#password").val();if(username == null){alert("請輸入用戶名");return;}$.ajax({url:'resume/login',type:'POST',    //GETasync:false,    //或false,是否異步data:{userid:username,password:password},timeout:5000,    //超時時間dataType:'json', //返回的數據格式:json/xml/html/script/jsonp/textsuccess:function(data){alert(data.message);if (data.code == '0') {window.location.href = 'list.jsp';}},failure:function (data) {}})})})</script>
</head>
<body><form action="./loginServlet" method="post"><table class="lp-login"><tr><td align="right"><span>用戶名</span></td><td align="center"><input type="text" id="username" name="username" placeholder="username"></input></td></tr><tr><td align="right"><span>密碼</span></td><td align="center"><input type="text" id="password" name="password" placeholder="password"></input></td></tr><tr align="center"><td colspan="2"><a class="loginBtn"><input type="submit" value="登陸"></a></td></tr></table>
</form></body>
</html><!-- list.jsp -->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="com.zhang.entity.User" %>
<%@ page import="java.util.List" %>
<%@ page import="com.zhang.service.UserService" %>
<%@ page import="com.zhang.service.impl.UserServceImpl" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en"><head><title>簡歷列表</title></head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">table, td{font:100% '微軟雅黑';}table{width:80%;border-collapse:collapse; margin:0 0 0 100px}th, td{text-align:center;border:1px solid #fff;}th{background:#328aa4}td{background:#e5f1f4;}
</style>
<script type="text/javascript" src="js/jquery-3.4.1.min.js"></script><script type="text/javascript">$(function(){loadResumeListData();let tds = $("td");tds.click(tdClick);});//添加點擊事件function addClickEvent() {//第一行綁定添加事件$("#add_btn").bind("click", function() {addNewLine(this);})//第一行綁定編輯事件$("#edit_btn").bind("click", function() {saveData(this);})//第一行綁定刪除事件$("#delete_btn").bind("click", function() {deleteData();})}//刪除數據function deleteData() {if(window.confirm("您確定要刪除數據嗎?")) {let id = $('table tr').eq(1).find("td").eq(0).text();$.ajax({url:'resume/delete',type:'POST',async:false,data:{id: id},timeout:5000,    //超時時間dataType:'json', //返回的數據格式:json/xml/html/script/jsonp/textsuccess:function(data){loadResumeListData();},failure:function (data) {}})}}function saveData(saveBtn) {let currLine = $(saveBtn).parent().parent().prevAll().length + 1;let id = $('table tr').eq(currLine).find("td").eq(0).text();let name = $('table tr').eq(currLine).find("td").eq(1).text();let address = $('table tr').eq(currLine).find("td").eq(2).text();let phone = $('table tr').eq(currLine).find("td").eq(3).text();$.ajax({url:'resume/update',type:'POST',async:false,data:{id: id,name: name,address: address,phone: phone},timeout:5000,    //超時時間dataType:'json', //返回的數據格式:json/xml/html/script/jsonp/textsuccess:function(data){alert("保存成功!");loadResumeListData();},failure:function (data) {}})}//給表格添加點擊事件,使表格可編輯function tdClick(){let tdnode = $(this);let tdtext = tdnode.text();if (tdtext == '修改   刪除' || tdtext == '新建') {return;}tdnode.html("");let input = $("<input>");input.val(tdtext);input.keyup(function(event){let myEvent = event || window.event;let keyCode = myEvent.keyCode;//判斷是否按下Entry鍵if(keyCode == 13) {let inputnode = $(this);let inputtext = inputnode.val();let td = inputnode.parent();td.html(inputtext);td.click(tdClick);}//判斷是否按下ESC鍵if(keyCode == 27) {$(this).parent().html(tdtext);$(this).parent().click(tdClick);}});tdnode.append(input);tdnode.children("input").trigger("select");//輸入框失去焦點,所執行的方法input.blur(function() {tdnode.html($(this).val());tdnode.click(tdClick);});tdnode.unbind("click");}<!--請求列表數據-->function loadResumeListData() {$.ajax({url:'resume/findList',type:'POST',async:false,data:{},timeout:5000,    //超時時間dataType:'json', //返回的數據格式:json/xml/html/script/jsonp/textsuccess:function(data){refreshList(data);addClickEvent();},failure:function (data) {}})}<!--刷新列表-->function refreshList(data) {let str1 = "";$("#resumeBody").html("");for(let i = 0; i<data.length; i++) {str1 = "<tr>" +"<td id=\"id\">" + data[i].id + "</td>" +"<td id=\"name\">" + data[i].name + "</td>" +"<td id=\"address\">" + data[i].address + "</td>" +"<td id=\"phone\">" + data[i].phone + "</td>" +"<td>" + "<a href=\"#\" id=\"edit_btn\">修改</a>" + "   " +"<a href=\"#\" id=\"delete_btn\">刪除</a>" +"</td>" +"</tr>";$("#resumeBody").append(str1);}}<!--添加一行-->function addNewLine() {let str1 = "";str1 = "<tr>" +"<td id=\"id\">" + "</td>" +"<td id=\"address\">" + "</td>" +"<td id=\"name\">" + "</td>" +"<td id=\"phone\">" + "</td>" +"<td>" + "<a href=\"#\" id=\"addNew_btn\">新建</a>" +"</td>" +"</tr>";$("#resumeBody").append(str1);let tds = $("td");tds.click(tdClick);$("#addNew_btn").bind("click", function() {saveData(this);})}
</script><!--繪制表格-->
<body>
<a href="./add.jsp" style ="margin:100px" id="add_btn">新增</a>
<form action=""></form>
<table id="tb"><c:forEach items="list"><tr id="listTable"><th style="width:100px" >ID</th><th style="width:100px" >姓名</th><th style="width:100px" >地址</th><th style="width:100px" >電話</th>
<%--        <th style="width:100px" >功能</th>--%></tr><th style="width:100px" > ${list.get(0).id}</th><th style="width:100px" > ${list.get(0).username}</th><th style="width:100px" > ${list.get(0).addr}</th><th style="width:100px" > ${list.get(0).tel}</th><br><th style="width:100px" > ${list.get(1).id}</th><th style="width:100px" > ${list.get(1).username}</th><th style="width:100px" > ${list.get(1).addr}</th><th style="width:100px" > ${list.get(1).tel}</th><br><tbody id="resumeBody"></tbody>
</table></c:forEach><%
//    UserService userService=new UserServceImpl();
//    List<User> list = userService.ALLUser();
//    out.println(list.get(0));
//    for (User user: list){
//     out.println(user);
//        out.println();
//    }
%>
</body>
</html>

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

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

相關文章

使用Nginx部署前端項目

使用Nginx部署前端項目 一、總述二、具體步驟 2.1解壓2.2將原來的html文件夾的文件刪除&#xff0c;將自己的靜態資源文件放進去&#xff0c;點擊nginx.exe文件啟動項目2.3查看進程中是否有ngix的兩個進程在瀏覽器中輸入“localhost:端口號”即可訪問。 2.4端口被占用情況處理 …

【論文學習】KAG論文翻譯

文章目錄KAG: Boosting LLMs in Professional Domains via Knowledge Augmented Generation摘要1 引言2 方法論2.1 LLM友好型知識表示2.2 互索引機制2.2.1 語義分塊2.2.2 帶豐富語境的的信息抽取2.2.3 領域知識注入與約束2.2.4 文本塊向量與知識結構的相互索引2.3 邏輯形式求解…

24黑馬SpringCloud安裝MybatisPlus插件相關問題解決

目錄 一、前言 二、菜單欄沒有Other 三、Config Database里的dburl需要加上時區等配置 一、前言 在學習24黑馬SpringCloud的MybatisPlus-12.拓展功能-代碼生成器課程時&#xff0c;發現由于IDEA版本不同以及MybatisPlus版本更新會出現與視頻不一致的相關問題&#xff0c;本博…

人工智能賦能聚合物及復合材料模型應用與實踐

近年來&#xff0c;生成式人工智能&#xff08;包括大語言模型、分子生成模型等&#xff09;在聚合物及復合材料領域掀起革命性浪潮&#xff0c;其依托數據驅動與機理協同&#xff0c;從海量數據中挖掘構效關系、通過分子結構表示&#xff08;如 SMILES、BigSMILES&#xff09;…

MyBatis-Plus3

一、條件構造器和常用接口 1.wapper介紹 MyBatis-Plus 提供了一套強大的條件構造器&#xff08;Wrapper&#xff09;&#xff0c;用于構建復雜的數據庫查詢條件。Wrapper 類允許開發者以鏈式調用的方式構造查詢條件&#xff0c;無需編寫繁瑣的 SQL 語句&#xff0c;從而提高開…

GXP6040K壓力傳感器可應用于醫療/汽車/家電

GXP6040K 系列壓力傳感器是一種超小型&#xff0c;為設備小型化做出貢獻的高精度半導體壓力傳感器&#xff0c;適用于生物醫學、汽車電子、白色家電等領域。采用標準的SOP6 和 DIP6 封裝形式&#xff0c;方便用戶進行多種安裝方式。 內部核心芯片是利用 MEMS&#xff08;微機械…

Android ConstraintLayout 使用詳解

什么是 ConstraintLayoutConstraintLayout&#xff08;約束布局&#xff09;是 Android Studio 2.2 引入的一種新型布局&#xff0c;現已成為 Android 開發中最強大、最靈活的布局管理器之一。它結合了 RelativeLayout 的相對定位和 LinearLayout 的線性布局優勢&#xff0c;能…

Unity3D數學第三篇:坐標系與變換矩陣(空間轉換篇)

Unity3D數學第一篇&#xff1a;向量與點、線、面&#xff08;基礎篇&#xff09; Unity3D數學第二篇&#xff1a;旋轉與歐拉角、四元數&#xff08;核心變換篇&#xff09; Unity3D數學第三篇&#xff1a;坐標系與變換矩陣&#xff08;空間轉換篇&#xff09; Unity3D數學第…

UV安裝并設置國內源

文章目錄一、UV下載1.官方一鍵安裝2.github下載安裝二、更換國內鏡像源&#xff08;加速下載&#xff09;方法1&#xff1a;臨時環境變量&#xff08;單次生效&#xff09;方法2&#xff1a;永久配置&#xff08;推薦&#xff09;方法3&#xff1a;命令行直接指定源三、驗證鏡像…

1 前言:什么是 CICD 為什么要學 CICD

什么是 CI/CD 我的資源庫網站&#xff1a;https://www.byteooo.cn 在開發階段&#xff0c;許多編譯工具會將我們的源碼編譯可使用的文件。例如 vue-cli 的項目會被 webpack 打包編譯為瀏覽器的文件&#xff0c;Java 項目會被編譯為 .class/jar 文件以供服務器使用。 但是&am…

GitHub 趨勢日報 (2025年07月30日)

&#x1f4ca; 由 TrendForge 系統生成 | &#x1f310; https://trendforge.devlive.org/ &#x1f310; 本日報中的項目描述已自動翻譯為中文 &#x1f4c8; 今日獲星趨勢圖 今日獲星趨勢圖3579copyparty752supervision664500-AI-Agents-Projects483awesome403prompt-optim…

“非參數化”大語言模型與RAG的關系?

這個問題觸及了一個關鍵的技術細節&#xff0c;兩者關系密切&#xff0c;但層面不同&#xff1a; “非參數化”大語言模型是一個更廣泛的概念或類別&#xff0c;而RAG&#xff08;Retrieval-Augmented Generation&#xff09;是實現這一概念最主流、最具體的一種技術框架。 您可…

LeetCode Hot 100:15. 三數之和

題目給你一個整數數組 nums &#xff0c;判斷是否存在三元組 [nums[i], nums[j], nums[k]] 滿足 i ! j、i ! k 且 j ! k &#xff0c;同時還滿足 nums[i] nums[j] nums[k] 0 。請你返回所有和為 0 且不重復的三元組。注意&#xff1a;答案中不可以包含重復的三元組。示例 1&…

銀行回單識別應用場景剖析

銀行回單OCR識別技術通過自動化處理紙質或電子回單中的關鍵信息&#xff0c;顯著提升了金融、企業及個人場景下的數據管理效率。以下是其核心應用場景及價值的詳細剖析&#xff1a;一、企業財務場景自動化賬務處理對賬與記賬&#xff1a;OCR自動提取交易日期、金額、賬號等信息…

React的介紹和特點

1. React是什么&#xff1f; 1.1. React&#xff1a; 用于構建用戶界面的JavaScript庫1.2. React的官網文檔&#xff1a;https://zh-hans.reactjs.org/ 2. React的特點2.1. 聲明式編程&#xff1a; 目前整個大前端開發的模式&#xff1a;Vue、React、Flutter、SwiftUI只需要維護…

內核smmu學習

思考 smmu對外提供功能&#xff0c;設備驅動調用smmu 提供的api來配置頁表&#xff0c;那其他設備是如何和smmu交互的&#xff1f;iommu 作為將不同smmu硬件的一個抽象封裝&#xff0c;其它設備應該只能看到iommu這個封裝層&#xff0c;那么iommu這個子系統是如何進行抽象的&a…

Android Slices:讓應用功能在系統級交互中觸手可及

引言 在當今移動應用生態中&#xff0c;用戶每天要面對數十個甚至上百個應用的選擇&#xff0c;如何讓自己的應用在關鍵時刻觸達用戶&#xff0c;成為開發者面臨的重要挑戰。Google在Android 9 Pie中引入的Slices技術&#xff0c;正是為了解決這一痛點而生。本文將全面介紹And…

python學智能算法(三十))|SVM-KKT條件的數學理解

【1】引言 前序學習進程中&#xff0c;通過類比力的平衡對KKT條件進行了初步的理解。 今天我們更進一步&#xff0c;常使用數學語言進一步解釋KKT條件。 【2】帶約束的最小優化問題 首先定義一個即將求解的優化問題&#xff1a; 目標函數&#xff1a;最小化f(x)(x∈Rn)f(x)(…

華為云Flexus+DeepSeek征文|Linux命令實現兩種部署的性能捕獲+(硅基+Maas)模型添加教學

前引&#xff1a;“在數字化浪潮洶涌澎湃的今天&#xff0c;企業對云計算服務的需求已從基礎架構支撐&#xff0c;逐步轉向更深層次的AI賦能與業務創新驅動。面對復雜多變的市場環境&#xff0c;選擇一個強大、可靠且具備前瞻性的云服務伙伴&#xff0c;無疑是企業實現高速增長…

langchain--1--prompt、output格式、LCEL示例

環境&#xff1a;本地使用ollama部署的deepseek-r1:1.5b模型 本文示例包含: [1] 非LCEL的調用方法[2] LCEL的調用方法[3] prompt template的簡單使用&#xff0c;除了PromptTemplate模板&#xff0c;還有一些其它模板&#xff0c;可去查看官網[4] 輸出&#xff1a;json格式、py…