0


GitHub官网下载Axios.js步骤

前言必读

读者手册(必读)_云边的快乐猫的博客-CSDN博客

一、下载步骤

1.进入GitHub官网

GitHub: Let’s build from here · GitHub

ps:进不去的多点几下,慢慢试

2.搜索axios

3.点击这个axios/axios

4.点击压缩包下载

5.解压,进入到dist文件里面就找到了

以下的可以不用看

二、使用方法

  1. 在webapp下创建一个js文件夹,然后把axios.js和axios.mim.js文件夹复制到里面

7.在webapp下创建一个html文件,并引入js文件夹中的axios.js文件。再创建两个axios的请求

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--引入的js文件-->
<script src="js/axios.js"></script>

<!--1.get请求-->
<script>
    axios.get("http://localhost:8080/maven_java_war/axioshello?username=zhangsan").then(function (resp) {
        alert(resp.data);
    })

//post请求
    axios.post("http://localhost:8080/maven_java_war/axioshello","username=lisi").then(function (resp) {
        alert(resp.data);
    })
</script>

</body>
</html>

8.请求访问这个servlet代码

package com.project.JavaScript;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/axioshello")
public class axioshello extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("get...");
        //1.接收请求参数
        String username = request.getParameter("username");
        System.out.println(username);
        //2.设置响应的数据
        response.getWriter().write("hello axios");
    }

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

运行结果为:

get...
post...
get...
zhangsan
lisi

ps:这是我上传的链接,可以直接下载使用

https://download.csdn.net/download/m0_52861000/87351507?spm=1001.2014.3001.5503


本文转载自: https://blog.csdn.net/m0_52861000/article/details/128467452
版权归原作者 云边的快乐猫 所有, 如有侵权,请联系我们删除。

“GitHub官网下载Axios.js步骤”的评论:

还没有评论