zoukankan      html  css  js  c++  java
  • return void ajax

    复制代码
    public class UserInfo {
        private String name;
        private Integer age;
    
        public String getName() {
            return name;
        }
    
        public void setName(String name) {
            this.name = name;
        }
    
        public Integer getAge() {
            return age;
        }
    
        public void setAge(Integer age) {
            this.age = age;
        }
    }
    复制代码
    复制代码
    @Controller
    public class json {
    @RequestMapping("/tojson")
        public void write(HttpServletRequest request, HttpServletResponse response) throws IOException {
        List<UserInfo> list=new ArrayList<UserInfo>();
        UserInfo u1=new UserInfo();
        u1.setName("啊啊");
        u1.setAge(22);
    
        UserInfo u2=new UserInfo();
        u2.setName("哈哈");
        u2.setAge(20);
    
        list.add(u1);
        list.add(u2);
    
    
        String re= JSON.toJSONString(list);
    
        response.getWriter().write(re);
    
    
    
        }
    
    }
    复制代码
    复制代码
    <%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
    <html>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>
    <script type="text/javascript">
        $(function () {
            $.ajax({
                url:"${pageContext.request.contextPath}/tojson",
                type:"post",
                data:{},
                success:function (data) {
                    alert(data);
                }
    
            });
        });
    
    
    
    </script>
    <body>
    <h2>流氓</h2>
    </body>
    </html>
    复制代码
  • 相关阅读:
    Design Pattern: Gof
    ZT --- extern "C"用法详解 2010-08-21 19:14:12
    OCR
    Linux strace命令
    wireshark esp
    https://sourceware.org/gdb/onlinedocs/gdb/Forks.html
    12306网上买火车票选择上中下铺的方法
    gdb调试有fork的程序
    named piped tcp proxy
    bash 提示用户输入 choice
  • 原文地址:https://www.cnblogs.com/zfx123--/p/7402440.html
Copyright © 2011-2022 走看看