Ajax、Axios、Vue、Element与其案例

目录

一.Ajax

二.Axios

三.Vue

四.Element 

 五.增删改查案例

一.依赖:数据库,mybatis,servlet,json-对象转换器

二.资源:element+vue+axios

三.pojo

 四.mapper.xml与mapper接口

五.service

 六.servlet

七.html页面


建立web工程

需要的依赖:

    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>1.2.62</version>
    </dependency>

一.Ajax

AJAX(Asynchronous JavaScript And XML):异步的js和xml
异步交互:与服务器交换数据并且更新部分网页的技术(局部刷新),操作无需等待服务器响应,直到数据响应回来才改变html页面
本案例使用ajax请求数据与处理响应数据,发送路径需要使用全路径

01ajax.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
</body>
<script>
    xhttp = new XMLHttpRequest();
    xhttp.open("GET", " http://localhost/web_demo5_ajax_war/ajaxServlet");
    xhttp.send();
    xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            alert(this.responseText);
        }
    };
</script>
</html>
@WebServlet("/ajaxServlet")
public class AJAXServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.getWriter().write("Hello,AJAX!");
    }
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}

 


二.Axios

Axios对原生的ajax封装,简化书写
使用准备:导入js文件,放到js文件里面,在本文件中引入js
本案例为使用axios用不同请求方式请求数据并处理响应数据

 02axios.html:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
<script src="js/axios-0.18.0.js"></script>
<script>
    axios.get("http://localhost/web_demo5_ajax_war/axiosServlet?username=zhangsan").then(resp=>{alert(resp.data)})
    axios.post("http://localhost/web_demo5_ajax_war/axiosServlet","username=zhangsan").then(resp=>{alert(resp.data)})
</script>
</html>
@WebServlet("/axiosServlet")
public class AxiosServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.getWriter().write(request.getMethod());
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}

浏览器弹窗为两种不同的请求方式

三.Vue

Vue是一套前端的框架,在js中简化Dom操作
使用需要:导入vue.js
1.改变框里面的值,对应的路径也改变
    1.绑定表单中的输入使用:v-model="url"
    2.绑定超链接跳转路径属性使用:v-bind:href="url"或:href="url"
    3.展示绑定模型的内容使用:{{}}}
2.点击按钮调用不同方法
    1.绑定事件元素使用:v-on:click="show()或者@click="show()"
    2.引入方法:在js的Vue模块中使用methods
3.通过输入展示不同标签
    1.if else:使用v-if="条件"属性
    2.展示内容与否:使用v-show标签
4.遍历模型:使用v-for=""属性
    在此案例中addr为局部变量名称,根据情况选择是否使用索引
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <input v-model="url"><br>
    <a v-bind:href="url">{{url}}</a><br>
    <a :href="url">{{url}}</a><br><br><br>

    <input type="button" value="按钮1" v-on:click="show()"><br>
    <input type="button" value="按钮2" @click="show()"><br><br><br>

    <div v-if="count==1">div1</div>
    <div v-else-if="count==2">div2</div>
    <div v-else>div3</div>
    <div v-show="count==4">div4</div>
    <input v-model="count"><br><br><br>

    <div v-for="addr in addrs">
        {{addr}}<br>
    </div>
    <div v-for="(addr,i) in addrs">
        {{i+1}}--{{addr}}<br>
    </div>
</div>
<script src="js/vue.js"></script>
<script>
    new Vue({//创建vue核心对象
        el:"#app",//作用范围
        methods:{//方法
            show(){
                alert("按钮被点击")
            }
        },
        data(){//模型数据
            return {
                url:"https://www.baidu.com",
                count:1,
                addrs:["北京","上海","西安"]
            }
        },
        mounted(){//页面加载完成后的方法
            alert("加载完成")
        }
    })
</script>
</body>
</html>

 


四.Element 

1.复制粘贴element-ui文件
2.引文件使用:然后去官网复制粘贴即可
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<div id="app">
    <el-row>
        <el-button>默认按钮</el-button>
        <el-button type="primary">主要按钮</el-button>
        <el-button type="success">成功按钮</el-button>
        <el-button type="info">信息按钮</el-button>
        <el-button type="warning">警告按钮</el-button>
        <el-button type="danger">危险按钮</el-button>
    </el-row>
</div>
</body>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<script>
  new Vue({
    el:"#app"
  })
</script>
</html>

 五.增删改查案例

新建Web项目

一.依赖:数据库,mybatis,servlet,json-对象转换器
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>5.1.32</version>
    </dependency>
    <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.5.5</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>javax.servlet-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>fastjson</artifactId>
      <version>1.2.62</version>
    </dependency>

二.资源:element+vue+axios

三.pojo

brand类中使用到了getStatusStr方法:由status返回字符串,交给别的类调用

public class Brand {
    private Integer id;
    private String brandName;
    private String companyName;
    private Integer ordered;
    private String description;
    private Integer status;
    public Brand() {
    }
    public Brand(Integer id, String brandName, String companyName, Integer ordered, String description, Integer status) {
        this.id = id;
        this.brandName = brandName;
        this.companyName = companyName;
        this.ordered = ordered;
        this.description = description;
        this.status = status;
    }
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getBrandName() {
        return brandName;
    }
    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }
    public String getCompanyName() {
        return companyName;
    }
    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }
    public Integer getOrdered() {
        return ordered;
    }
    public void setOrdered(Integer ordered) {
        this.ordered = ordered;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public Integer getStatus() {
        return status;
    }
    public String getStatusStr(){
        if(this.status==1){ return "启用"; }
        return "禁用";
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Override
    public String toString() {
        return "Brand{" +
                "id=" + id +
                ", brandName='" + brandName + '\'' +
                ", companyName='" + companyName + '\'' +
                ", ordered=" + ordered +
                ", description='" + description + '\'' +
                ", status=" + status +
                '}';
    }
}

pagebean类用于存放一页的数据与总数量

public class PageBean<T> {
    private int totalCount;
    private List<T> rows;
    public PageBean() {
    }
    public PageBean(int totalCount, List<T> rows) {
        this.totalCount = totalCount;
        this.rows = rows;
    }
    public int getTotalCount() {
        return totalCount;
    }
    public void setTotalCount(int totalCount) {
        this.totalCount = totalCount;
    }
    public List<T> getRows() {
        return rows;
    }
    public void setRows(List<T> rows) {
        this.rows = rows;
    }
}

 四.mapper.xml与mapper接口

 使用到了批量删除、模糊查询、分页查询

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.example.mapper.BrandMapper">
    <resultMap id="brandResultMap" type="Brand">
        <id column="id" property="id"/>
        <result column="brand_name" property="brandName"/>
        <result column="company_name" property="companyName"/>
    </resultMap>
    <delete id="deleteByIds">
        delete from tb_brand where id in
        <foreach collection="array" item="id" separator="," open="(" close=")">
            #{id}
        </foreach>;
    </delete>
    <select id="selectByPageAndCondition" resultMap="brandResultMap">
        select *
        from tb_brand
        <where>
            <if test="brand.status!=null">
                and  status=#{brand.status}
            </if>
            <if test="brand.companyName!=null and brand.companyName!=''">
                and company_name like #{brand.companyName}
            </if>
            <if test="brand.brandName!=null and brand.brandName!=''">
                and brand_name like #{brand.brandName}
            </if>
        </where>
        limit #{begin},#{size}
    </select>
    <select id="selectCountByCondition" resultType="java.lang.Integer">
        select count(*) from tb_brand
        <where>
            <if test="status!=null">
                and  status=#{status}
            </if>
            <if test="companyName!=null and companyName!=''">
                and company_name like #{companyName}
            </if>
            <if test="brandName!=null and brandName!=''">
                and brand_name like #{brandName}
            </if>
        </where>
    </select>
</mapper>
public interface BrandMapper {
    //添加数据
    @Insert("insert into tb_brand values(null,#{brandName},#{companyName},#{ordered},#{description},#{status})")
    void add(Brand brand);
    //删除数据
    @Delete("delete from tb_brand where id=#{id}")
    void deleteById(int id);
    //更新数据
    @Update("update tb_brand set brand_name=#{brandName}," +
            "company_name=#{companyName}," +
            "ordered=#{ordered}," +
            "description=#{description}," +
            "status=#{status} " +
            "where id=#{id}")
    void update(Brand brand);
    //删除选中数据
    void deleteByIds(int[] ids);
    //条件分页查询
    int selectCountByCondition(Brand brand);
    List<Brand> selectByPageAndCondition(@Param("begin") int begin, @Param("size") int size, @Param("brand") Brand brand);

}

五.service
public class BrandService {
    SqlSessionFactory factory = SqlSessionFactoryUtil.getssf();
    public void add(Brand brand) {
        SqlSession sqlsession=factory.openSession(true);
        sqlsession.getMapper(BrandMapper.class).add(brand);
        sqlsession.close();
    }
    public void deleteById(int id) {
        SqlSession sqlsession=factory.openSession(true);
        sqlsession.getMapper(BrandMapper.class).deleteById(id);
        sqlsession.close();
    }
    public void update(Brand brand) {
        SqlSession sqlsession=factory.openSession(true);
        sqlsession.getMapper(BrandMapper.class).update(brand);
        sqlsession.close();
    }
    public void deleteByIds(int[] ids) {
        SqlSession sqlsession=factory.openSession(true);
        sqlsession.getMapper(BrandMapper.class).deleteByIds(ids);
        sqlsession.close();
    }
    public PageBean<Brand> selectByPageAndCondition(int currentPage, int pageSize, Brand brand) {
        SqlSession sqlsession=factory.openSession(true);
        BrandMapper mapper=sqlsession.getMapper(BrandMapper.class);
        String brandName=brand.getBrandName();
        if(brandName!=null && !brandName.isEmpty()) brand.setBrandName("%"+brandName+"%");
        String companyName=brand.getCompanyName();
        if(companyName!=null && !companyName.isEmpty()) brand.setCompanyName("%"+companyName+"%");

        PageBean<Brand> pageBean=new PageBean<>(mapper.selectCountByCondition(brand),
                        mapper.selectByPageAndCondition((currentPage-1)*pageSize,pageSize,brand));
        sqlsession.close();
        return pageBean;
    }
}

 六.servlet

服务类中使用反射判别不同的请求路径去访问不同方法

public class BaseServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String uri=req.getRequestURI();
        String methodName=uri.substring(uri.lastIndexOf('/')+1);
        Class<? extends BaseServlet> cls=this.getClass();
        try{
            Method method=cls.getMethod(methodName,HttpServletRequest.class,HttpServletResponse.class);
            method.invoke(this,req,resp);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}

分页+模糊查询同时使用到了post+get方法

@WebServlet("/brand/*")
public class BrandServlet extends BaseServlet{
    private final BrandService service =new BrandService();
    public void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("add...");
        service.add(JSON.parseObject(request.getReader().readLine(),Brand.class));
        response.getWriter().write("success");
    }
    public void deleteById(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        System.out.println("deleteById...");
        service.deleteById(Integer.parseInt(request.getParameter("id")));
        response.getWriter().write("success");
    }
    public void update(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        System.out.print("update...");
        service.update(JSON.parseObject(request.getReader().readLine(),Brand.class));
        response.getWriter().write("success");
    }
    public void deleteByIds(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        System.out.print("deleteMany...");
        service.deleteByIds(JSON.parseObject(request.getReader().readLine(),int[].class));
        response.getWriter().write("success");
    }
    //post+get方式来实现分页查询+条件查询,条件查询可有可无
    public void selectByPageAndCondition(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("brand selectByPageAndCondition...");
        response.setContentType("text/json;charset=UTF-8");
        response.getWriter().write(
                JSON.toJSONString(
                        service.selectByPageAndCondition(
                                Integer.parseInt(request.getParameter("currentPage")),
                                Integer.parseInt(request.getParameter("pageSize")),
                                JSON.parseObject(request.getReader().readLine(),Brand.class)
                        )));
    }
}

七.html页面
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <!--查询表单-->
    <el-form :inline="true" :model="brandSelect" class="demo-form-inline">
        <el-form-item label="当前状态">
            <el-select v-model="brandSelect.status" placeholder="当前状态">
                <el-option label="启用" value="1"></el-option>
                <el-option label="禁用" value="0"></el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="企业名称">
            <el-input v-model="brandSelect.companyName" placeholder="企业名称"></el-input>
        </el-form-item>
        <el-form-item label="品牌名称">
            <el-input v-model="brandSelect.brandName" placeholder="企业名称"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="selectAll">查询</el-button>
        </el-form-item>
    </el-form>
    <!--新增与批量删除按钮-->
    <el-row>
        <el-button type="danger" plain @click="deleteByIds">批量删除</el-button>
        <el-button type="primary" plain @click="handleAdd">新增</el-button>
    </el-row>
    <!--添加数据与修改数据的对话框表单-->
    <el-dialog
            title="编辑品牌"
            :visible.sync="dialogVisible"
            width="30%">
        <el-form ref="form" :model="brand" label-width="80px">
            <el-form-item label="品牌名称">
                <el-input v-model="brand.brandName"></el-input>
            </el-form-item>
            <el-form-item label="企业名称">
                <el-input v-model="brand.companyName"></el-input>
            </el-form-item>
            <el-form-item label="排序">
                <el-input v-model="brand.ordered"></el-input>
            </el-form-item>
            <el-form-item label="备注">
                <el-input type="textarea" v-model="brand.description"></el-input>
            </el-form-item>
            <el-form-item label="状态">
                <el-switch v-model="brand.status"
                           active-color="#13ce66"
                           inactive-color="#ff4949"
                           active-value="1"
                           inactive-value="0">
                </el-switch>
            </el-form-item>
            <!--点击事件设立一下-->
            <el-form-item>
                <template v-if="method=='修改'">
                    <el-button type="primary" @click="updateBrand">提交修改</el-button>
                </template>
                <template v-else>
                    <el-button type="primary" @click="addBrand">提交添加</el-button>
                </template>
                <el-button @click=cancelUpdate>取消</el-button>
            </el-form-item>
        </el-form>
    </el-dialog>
    <!--表格-->
    <el-table
            :data="tableData"
            style="width: 100%"
            stripe
            @selection-change="handleSelectionChange">
        <el-table-column
                type="selection">
        </el-table-column>
        <el-table-column
                label="排序"
                type="index">
        </el-table-column>
        <el-table-column
                prop="brandName"
                label="品牌名称"
                align="center">
        </el-table-column>
        <el-table-column
                prop="companyName"
                label="企业名称"
                align="center">
        </el-table-column>
        <el-table-column
                prop="ordered"
                align="center"
                label="排序">
        </el-table-column>
        <!--取值为statusStr,找到Brand里面的对应的get方法-->
        <el-table-column
                prop="statusStr"
                align="center"
                label="当前状态">
        </el-table-column>
        <el-table-column label="操作" align="center">
            <template slot-scope="scope">
                <el-button
                        type="primary"
                        @click="handleEdit(scope.$index, scope.row)">编辑
                </el-button>
                <el-button
                        type="danger"
                        @click="handleDelete(scope.$index, scope.row)">删除
                </el-button>
            </template>
        </el-table-column>
    </el-table>
    <!--分页-->
    <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount">
    </el-pagination>
</div>
<script src="js/axios-0.18.0.js"></script>
<script src="js/vue.js"></script>
<script src="element-ui/lib/index.js"></script>
<link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
<script>
    new Vue({
        el: "#app",
        mounted() {
            this.selectAll();
        },
        data() {
            return {
                //表内数据与查询的数据
                tableData: [],
                brandSelect: {
                    status: '',
                    brandName: '',
                    companyName: '',
                    description: '',
                    id: '',
                    ordered: '',
                },
                //add与update表单显示开关,方法选择,使用的模型
                dialogVisible: false,
                method: '',
                brand: {},
                //复选框数据,选中的要删除的数据
                multipleSelection: [],
                selectedIds: [],
                //分页数据
                pageSize: 5,
                totalCount: 100,
                currentPage: 1,
            }
        },
        methods: {
            //添加功能与修改功能
            handleAdd() {
                this.method = '添加';
                this.brand = {
                    status: '',
                    brandName: '',
                    companyName: '',
                    description: '',
                    id: '',
                    ordered: '',
                };
                this.dialogVisible = true
            },
            handleEdit(index, row) {
                this.method = '修改'
                this.brand = this.tableData[index];
                this.brand.status = String(this.brand.status)
                this.dialogVisible = true;
            },
            addBrand() {
                axios.post("http://localhost/web_demo6_war/brand/add", this.brand).then(resp => {
                    if (resp.data == "success") {
                        this.dialogVisible = false;
                        this.$message({
                            message: '添加成功',
                            type: 'success'
                        });
                        this.selectAll();
                    }
                })
            },
            updateBrand() {
                axios.post("http://localhost/web_demo6_war/brand/update", this.brand).then(resp => {
                    if (resp.data == "success") {
                        this.dialogVisible = false;
                        this.$message({
                            message: '修改成功',
                            type: 'success'
                        });
                        this.selectAll();
                    }
                })
            },
            cancelUpdate() {
                this.dialogVisible = false
                this.$message({
                    message: '已取消修改',
                });
                this.selectAll()
            },

            //删除功能
            handleDelete(index, row) {
                this.$confirm('此操作将永久删除改公司信息, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.get("http://localhost/web_demo6_war/brand/deleteById?id=" + this.tableData[index].id).then(resp => {
                        if (resp.data == "success") {
                            this.$message({
                                message: '删除成功',
                                type: 'success'
                            });
                            this.selectAll();
                        }
                    })
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },

            //批量删除功能
            handleSelectionChange(val) {
                this.multipleSelection = val;
                console.log(this.multipleSelection);
            },
            deleteByIds() {
                for (let i = 0; i < this.multipleSelection.length; i++) {
                    let selectedElement = this.multipleSelection[i];
                    this.selectedIds[i] = selectedElement.id;
                }
                this.$confirm('此操作将永久删除改公司信息, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    if (this.selectedIds.length != 0) {
                        axios.post("http://localhost/web_demo6_war/brand/deleteByIds", this.selectedIds).then(resp => {
                            if (resp.data == "success") {
                                this.$message({
                                    message: '删除成功',
                                    type: 'success'
                                });
                                this.selectAll();
                            }
                        })
                        this.selectedIds = [];
                    } else {
                        this.$message({
                            message: '需要选中几个数据',
                            type: 'warning'
                        });
                    }
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },


            //分页工具条方法
            handleSizeChange(val) {
                console.log(`每页 ${val} 条`);
                this.pageSize = val;
                this.selectAll();
            },
            handleCurrentChange(val) {
                console.log(`当前页: ${val}`);
                this.currentPage = val;
                this.selectAll();
            },
            //查询分页:
            selectAll() {
                axios.post("http://localhost/web_demo6_war/brand/selectByPageAndCondition?currentPage=" + this.currentPage + "&pageSize=" + this.pageSize,
                    this.brandSelect).then(resp => {
                    this.tableData = resp.data.rows;
                    this.totalCount = resp.data.totalCount;
                    console.log(this.tableData);
                })
            },
        }
    })
</script>
</body>
</html>

 

  

在本文的最后,说一些最近的感想:

学习这类技术似乎不能太认真,或许会浪费大把的时间

“作数”或许就行了!

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

产品展示型wordpress外贸网站模板

孕婴产品wordpress外贸网站模板 吸奶器、待产包、孕妇枕头、护理垫、纸尿裤、孕妇装、孕婴产品wordpress外贸网站模板。 https://www.jianzhanpress.com/?p4112 床品毛巾wordpress独立站模板 床单、被套、毛巾、抱枕、靠垫、围巾、布艺、枕头、乳胶枕、四件套、浴巾wordpre…

请说明Vue中的异步组件加载

Vue中的异步组件加载是指当页面需要渲染某个组件时&#xff0c;可以在需要时再去加载这个组件&#xff0c;而不是在页面初始化的时候就将所有组件一次性加载进来。这种方式能够有效降低页面的初始加载时间&#xff0c;提升用户体验。 在Vue中&#xff0c;我们可以使用import函…

Dgraph 入门教程三(linux本地部署)

上一章中&#xff0c;我们用的官方的Clound操作的&#xff0c;怎么在本地部署一套Dgraph呢。这一章将做详细介绍。安装有好几种方式&#xff0c;最简单的就是联网部署。因为项目需要&#xff0c;这里先不介绍和测试线上部署了&#xff0c;只介绍离线部署。 1、下载安装包 Rel…

flask 数据库迁移报错 Error: No such command ‘db‘.

初学FLASK&#xff0c;使用pycharm的terminal 启动&#xff0c;实现数据库迁移 文件结构 项目启动文件不在一级目录pycharm>terminal启动 由于自己初入 python flask 很多东西并不懂&#xff0c;只能依葫芦画瓢&#xff0c;使用如下命令,输入完第一行命令执行没有任何错误…

Android Termux系统安装openssh实现公网使用SFTP远程访问

文章目录 1. 安装openSSH2. 安装cpolar3. 远程SFTP连接配置4. 远程SFTP访问4. 配置固定远程连接地址 SFTP&#xff08;SSH File Transfer Protocol&#xff09;是一种基于SSH&#xff08;Secure Shell&#xff09;安全协议的文件传输协议。与FTP协议相比&#xff0c;SFTP使用了…

力扣写法题:最后一个单词的长度

如果最后一个单词后有空格可以采用以下的写 int lengthOfLastWord(char* s) {int count0,flag0;int i(strlen(s)-1);while(i>0){if(s[i]! ) flag1;if(flag1) {if(s[i] ) break;else count;}i--;}return count; }

IAR全面支持小华全系芯片,强化工控及汽车MCU生态圈

IAR Embedded Workbench for Arm已全面支持小华半导体系列芯片&#xff0c;加速高端工控MCU和车用MCU应用的安全开发 嵌入式开发软件和服务的全球领导者IAR与小华半导体有限公司&#xff08;以下简称“小华半导体”&#xff09;联合宣布&#xff0c;IAR Embedded Workbench fo…

STM32CubeMX学习笔记14 ---SPI总线

1. 简介 1.1 SPI总线介绍 SPI 是英语Serial Peripheral interface的缩写&#xff0c;顾名思义就是串行外围设备接口。是Motorola(摩托罗拉)首先在其MC68HCXX系列处理器上定义的。 SPI&#xff0c;是一种高速的&#xff0c;全双工&#xff0c;同步的通信总线&#xff0c;并且在…

如何把网页调用变为代码调用

1.背景 最近有一个需求&#xff0c;猜测一段十六进制流的校验方式&#xff0c;挨个尝试非常耗时&#xff0c;需要写代码&#xff0c;调用网页上的功能。 2.解决方案 可以使用Python的 requests 库来发起HTTP请求&#xff0c;并通过POST请求将数据发送给服务器进行计算CRC校验和…

类和对象周边知识

再谈构造函数 前几期我们把六个默认成员函数一一说明后&#xff0c;构造函数还有一些周边知识。 初始化列表 我们在没有了解初始化列表的时候一般都是使用构造函数初始化或者在声明哪里给予缺省值&#xff0c;那么为什么好药存在初始化列表呢&#xff1f;是因为①.有些值必须…

Java后台面试相关知识点解析

文章目录 JavaJava中四种引用类型及使用场景集合HashMap源码及扩容策略HashMap死循环问题ConcurrentHashMap与HashtableConCurrentHashMap 1.8 相比 1.7 判断单链表是否有环&#xff0c;并且找出环的入口IO线程池线程池的几种创建方式判断线程是否可以回收线程池的7大核心参数线…

【实战】K8S集群部署nacos并接入Springcloud项目容器化运维

文章目录 前言Nacos集群搭建Spring cloud配置nacos将Springcloud项目部署在k8s写在最后 前言 相信很多同学都开发过以微服务为架构的系统&#xff0c;开发微服务必不可少要使用注册中心&#xff0c;比如nacos\consul等等。当然在自动化运维流行的今天&#xff0c;我们也会将注…

Qt6.6搭建WebAssembly

1.首先安装python &#xff0c; 链接&#xff1a;https://www.python.org/ 2.下载并安装qt6. 3.克隆emsdk工程 3.1 进入emsdk目录&#xff0c;然后更新emsdk代码 3.2 下载并安装最新的SDK工具。&#xff08;C:\Qt\emsdk>emsdk install --global latest&#xff09; 3.3…

一周学会Django5 Python Web开发-Django5修改视图UpdateView

锋哥原创的Python Web开发 Django5视频教程&#xff1a; 2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~_哔哩哔哩_bilibili2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~共计31条视频&#xff0c;包括&#xff1a;2024版 Django5 Python we…

Sui RFP两个提案正在悬赏Grant,4月1日截止速来申请

项目1&#xff1a;智能合约模板市场 概述 创建一个供开发人员购买或提供智能合约模板的市场。针对这样一个特定用户群体&#xff0c;制定支持所需动态的激励机制至关重要。 问题描述 随着众多区块链使用EVM&#xff0c;这些生态中的开发人员受益于各种应用程序和智能合约示…

Linux系统 -- 信号

一 信号的概念 在我们的日常生活中&#xff0c;红绿灯其实也叫信号灯&#xff0c;因此&#xff0c;我们将用红绿灯给大家讲解一下信号的概念。 当你开着车经过红绿灯路口时&#xff0c;你也在收到红绿灯给你的通知&#xff0c;假设是红灯&#xff0c;那么你就需要停下来等待&am…

【MySQL】lower_case_table_names作用及使用

知识点&#xff1a; lower_case_table_names 是mysql设置大小写是否敏感的一个参数。 场景&#xff1a;在使用dataease时&#xff0c;连接外部数据库&#xff0c;启动报错&#xff01;后查看官方文档&#xff0c;特别要求改数据库配置文件&#xff1a;lower_case_table_names …

linux系统---selinux

目录 前言 一、SELinux 的作用及权限管理机制 1.SELinux 的作用 1.1DAC 1.2MAC 1.3DAC 和 MAC 的对比 2.SELinux 基本概念 2.1主体&#xff08;Subject&#xff09; 2.2对象&#xff08;Object&#xff09; 2.3政策和规则&#xff08;Policy & Rule&#xff09; …

MybatisPlus入门详解

一、MyBatisPlus 简介 1.1 创建新模块 <dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>3.4.1</version></dependency> 由于mp并未被收录到idea的系统内置配置,无法…

停工待料,责任真的全在PMC吗?天行健深度剖析背后的原因

在现代制造业中&#xff0c;停工待料的现象时有发生&#xff0c;这不仅影响了生产进度&#xff0c;还增加了企业的运营成本。很多人会自然而然地将责任归咎于生产物料控制&#xff08;PMC&#xff09;部门&#xff0c;认为是他们没有做好物料计划和管理。但事实上&#xff0c;停…