'Spring -- DataTables Checkbox selection cannot be deleted

I'm posting my first question on Stack Overflow. When I try to remove the checked data from the data table, it doesn't work. Is there a problem with my code?

Is it right to receive data from DAO, Service, and Service Impl using Map<String,Object>commandMap?

JSP

    <table id="tableDemo" class="display">

         <thead>

                 <tr>

                     <th></th>

                     <th data-orderable="false">No.</th>

                      <th>그룹코드</th>

                     <th>그룹명</th>

                      <th>코드</th>

                     <th>코드명</th>

                     <th>사용여부</th>

                 </tr>

         </thead>

        <tbody>

        <c:set var="count" value="1"/>

        <c:forEach var="list" items="${resultlist }" varStatus="status">

          <tr>

            <td><input style="zoom:1.3;" type="checkbox" name="test" value=${list.codegid }></td>

            <td>${count }</td>

            <td>${list.codegid }</td>

            <td>${list.codegnm }</td>

            <td>${list.code }</td>

            <td>${list.codenm }</td>

            <td>${list.useat }</td>

            <c:set var="count" value="${count+1}"/>

          </tr>

          </c:forEach>

    </tbody>

 </table>

  <a id="delete" class="btn blue" >삭제</a>

</div>

script

$("#delete").on("click", function() {

            if (confirm(" 삭제하시겠습니까?")==true) {
                var cnt = $("input[name='test']:checked").length; 

                var ids = new Array;

                $("input[name='test']:checked").each(function() {
                    ids.push($(this).val('id'));

                });

                if(cnt == 0){
                    alert("선택된 글이없습니다.");

                }

                else{
                    $.ajax = {
                        type: "POST",

                        url: "<c:url value='/codeDelete.do'",

                        data: "codegid="+ ids + "&CNT=" + cnt,

                        dataType: "json"

                    }

            }

        }

});

Controller

        @RequestMapping(value="/codeDelete.do")

        @ResponseBody

        public int deleteCodes(Map<String,Object> commandMap) throws Exception{
            int result=1;

            try {
                int cnt = Integer.parseInt((String) commandMap.get("CNT"));

                String rprtOdr = (String)commandMap.get("codegid");

                String [] strArray = rprtOdr.split(",");

                System.out.println("list ===>>" + strArray);

                for(int i=0; i<cnt; i++) {
                    String temp = ((String)strArray[i]);

                    commandMap.put("codegid", temp);

                   codeService.deleteCodes("codetDAO.deleteCodes", commandMap);

                }

            } catch (Exception e) {
                log.debug(e.getMessage());

                result=0;

            }

            return result;

    }

}

serviceImpl

@Service("codeService")

public class CodeServiceImpl implements CodeService {

@Resource(name="codeDAO")

private CodeDAO codeDAO;


    @Override

public void deleteCodes(String string, Map<String, Object> commandMap){
    codeDAO.deleteCodes(commandMap)     

}

DAO

@Repository("codeDAO")

public class CodeDAO extends EgovAbstractDAO{


  public void deleteCodes(Map<String, Object> commandMap) {
        delete("codeDAO.deleteCodes",commandMap);

    }

SQL

<delete id="codeDAO.deleteCodes">

        <![CDATA[

        UPDATE  codes

               SET  USE_AT  = 'N'

             WHERE codegid = #codegid#

             ]]>
</delete>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source