zoukankan      html  css  js  c++  java
  • Ajax && json(原始)

    function findSend() {
            $.ajax({
    //            async: false,
    //            cache: true,
                type: "POST",
                url: "InMessageServlet?action=findSend",
                data: $('#receiveForm').serialize(),// 你的formid
                dataType: 'json',
    //            error: function(request) {
    
    //            },
                success: function (data) {
    //                alert(data.success);
    //            window.location.href = "InMessageServlet?action=one";
    
                }
            });
        };
    public void findSend(HttpServletRequest request, HttpServletResponse response) throws Exception {

    List<InMessage> list = new ArrayList<InMessage>();
    InMessage im = new InMessage();
    。。。。。。
    list.add(im);
    JSONArray json = new JSONArray();
    for (InMessage a : list) {
    JSONObject jo = new JSONObject();
    jo.put("mainMessage", a.getMainMessage());
    jo.put("sendUserName", a.getSendUserName());
    json.put(jo);
    }
    request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");

    response.setContentType("text/json");
    PrintWriter out = response.getWriter();

    out.print(json);
    out.flush();
    out.close();
    }
    ------
    Map<String, Object> jsonMap = new HashMap<String, Object>();//定义map
    jsonMap.put("plist",plist);
    jsonMap.put("simlistObj",simlistObj);


    JSONObject result = JSONObject.fromObject(jsonMap);
    response.setContentType("text/json");
    PrintWriter out = response.getWriter();

    out.print(result);
    out.flush();
    out.close();



      

  • 相关阅读:
    Laravel中Contracts的理解和使用
    laravel 服务容器的用法
    linux 安装go环境
    权限设计-系统登录用户权限设计
    Laravel 中使用 JWT 认证的 Restful API
    使用laravel-wechat微信支付
    composer查看全局配置
    如何在 Laravel 项目中处理 Excel 文件
    laravel各种请求类
    Centos创建用户并授权
  • 原文地址:https://www.cnblogs.com/jwlfpzj/p/6834591.html
Copyright © 2011-2022 走看看