zoukankan      html  css  js  c++  java
  • json转化对特殊字段的处理

            //获取部门id
            String departmentId = (String)this.getRequest().getParameter("departmentId");
            //根据部门id查询用户list
            List<Admin> adminList = adminService.findAllListBydepartment(departmentId);
            try {
                JsonConfig jsonConfig = new JsonConfig();  //建立配置文件
                jsonConfig.setIgnoreDefaultExcludes(false);  //设置默认忽略
                jsonConfig.setExcludes(new String[]{"roles"}); //此处是亮点,只要将所需忽略字段加到数组中即可
                
                HttpServletResponse response = this.getResponse();
                response.setContentType("text/plain;charset=UTF-8");
                JSONArray array = JSONArray.fromObject(adminList, jsonConfig);
                response.getWriter().print(array);
            } catch (Exception e) {
                e.printStackTrace();
            }
  • 相关阅读:
    form表单介绍
    if条件语句
    表格.html
    列表.html
    CSS Js链接HTML文件
    DQL
    mysql介绍
    第一次接触mysql
    逻辑运算、作用域问题、DOM
    Js数据类型具体分析
  • 原文地址:https://www.cnblogs.com/kisstear/p/5606922.html
Copyright © 2011-2022 走看看