zoukankan      html  css  js  c++  java
  • 【Java】逗号拼接的取巧处理

    需求如图:

    这是表的关键处理数据,页面上的输入框要做分开展示,也就是要写业务逻辑来处理

    逗号拼接的取巧处理,使用了List集合toString方法来实现,然后移除括号

    final String employeeSql = "SELECT TYPE, `NAME`, PHONE FROM tt_foresee_maintain_order_employee WHERE ORDER_ID = ? ";
    List<TtForeseeMaintainOrderEmployeePO> employeeList = TtForeseeMaintainOrderEmployeePO.findBySQL(employeeSql, id); // id 1353
    if (employeeSql != null && employeeList.size() > 0) {
        List<String> ctos = new LinkedList<String>();
        List<String> ctoPhones = new LinkedList<String>();
        List<String> claimants =  new LinkedList();
        List<String> claimantPhones =  new LinkedList();
        for (int i = 0; i < employeeList.size(); ++i) {
            TtForeseeMaintainOrderEmployeePO employee = employeeList.get(i);
            if ( "1".equals(employee.get("TYPE").toString())) {
                ctos.add(employee.get("NAME").toString() );
                ctoPhones.add(employee.get("PHONE").toString());
            } else {
                claimants.add(employee.get("NAME").toString());
                claimantPhones.add(employee.get("PHONE").toString());
            }
        }
        map.put("cto_name", ctos.toString().replaceAll("\[|\]", ""));
        map.put("cto_phone", ctoPhones.toString().replaceAll("\[|\]", ""));
        map.put("claimant_name", claimants.toString().replaceAll("\[|\]", ""));
        map.put("claimant_phone", claimantPhones.toString().replaceAll("\[|\]", ""));
    }
  • 相关阅读:
    C#中ToString格式大全
    mysql事务
    Mac eclipse 启动卡住
    Mac 安装zkdash
    Mac 安装SecureCRT
    java多线程、并发系列之 (synchronized)同步与加锁机制
    jvm 年轻代
    查看日志技巧
    which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
    tomcat限制内存
  • 原文地址:https://www.cnblogs.com/mindzone/p/14718291.html
Copyright © 2011-2022 走看看