• 【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("\[|\]", ""));
    }
  • 相关阅读:
    maven的tomcat插件如何进行debug调试
    jre,jdk,jvm的关系
    maven私服Nexus3.2的使用
    Markdown插入图表
    GAME-BASED LEARNING
    Game Based Learning: Why Does it Work?
    31 Game-Based Learning Resources for Educators
    Gamification and Game-Based Learning
    Gamification vs. Game-Based Learning
    WHAT IS GAME-BASED LEARNING?
  • 原文地址:https://www.cnblogs.com/mindzone/p/14718291.html
Copyright © 2020-2023  润新知