zoukankan      html  css  js  c++  java
  • 自己用的各种工具类(不喜勿喷)

    1:List转Json

    public static String list2JsonArray(List list) {
            StringBuffer str = new StringBuffer("[");
            if (list != null && list.size() > 0) {
                int len = list.size();
                Object map = null;
    
                for (int i = 0; i < len; i++) {
                    map = list.get(i);
                    if (i > 0) {
                        str.append(",");
                    }
                    str.append(JSONUtil.object2json(map));
                }
            }
            str.append("]");
            return str.toString();
        }

    2:ajax向前端返回json字符串

    //向前端返回json字符串
        public void outString(String json) {
            PrintWriter print = null;
            try {
                HttpServletResponse response;
                response = this.getResponse();
                response.setContentType("text/json;charset=UTF-8");
                response.setHeader("Cache-Control", "no-cache");
                response.setHeader("Pargma", "no-cache");
                response.setDateHeader("Expires", 0);
                print = this.getResponse().getWriter();
                print.write(json);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
  • 相关阅读:
    菜单导航组件
    flask+nginx+uwsgi在服务器搭建项目
    安装Anaconda
    vscode上eslink包失效
    js滚动事件
    打字游戏
    js更高文档的样式
    js事件
    Dom对象更改文档结构.html
    js重点
  • 原文地址:https://www.cnblogs.com/dnxf/p/4173482.html
Copyright © 2011-2022 走看看