• js


    1.使用jquery发送前台请求给服务器,并显示数据

    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <html>
    <head>
        <title>success</title>
    </head>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">
    </script>
    <script type="text/javascript">function change() {
            $.ajax({
                type : "GET",
                url : "/abc2",
                data : {
                    "user": "wangerxiao"
                },
                success : function(result) {
                    alert(result)
                }
            });
        }
    </script>
    <body>
    <h1>this is success page</h1>
    <h2>${msg}</h2>
    <div class="form" style=" 100px;height: 100px;background-color: red" onclick="change()">
    </div>
    </body>
    </html>

    2.后台接受前台请求,并发送相应

    @Controller
    public class HelloController {
        @GetMapping("/abc2")
        @ResponseBody
        public Map<String,Object> hello2(@RequestParam("user")String user){
            System.out.println(user);
            List<String> list = new ArrayList<>();
            list.add("a");
            list.add("b");
            list.add("c");
            Map<String,Object> map = new HashMap<>();
            map.put("1","王二小");
            map.put("2","刘明");
            map.put("3","张三");
            return map;
        }
    }

  • 相关阅读:
    Nulls first和nulls last
    json.parse()和json.stringify()
    将单个的.java文件通过javac编辑为.class文件
    看别人项目思路:
    我想成为怎样的人?
    装逼语录:
    Uncompressing Linux... done, booting the kernel
    linux 内核模块最小环境编译
    select 定时器
    mount
  • 原文地址:https://www.cnblogs.com/20158424-hxlz/p/10407208.html
Copyright © 2020-2023  润新知