title: I want to call the controller of SpringMVC with Ajax when I click the radio button
body: <p>For example, if I select radio button 1 and press the submit button, I want to call controller 1, select radio button 2, and press button 2 to call controller 2.</p>
  
  <p>Below is the method I tried. There are two controllers first.</p>
  
  <pre><code>@RequestMapping(value="/ynto10", method=RequestMethod.POST)
  public String ynto10(HttpServletRequest req, HttpServletResponse res) {
  
      String[] columns = req.getParameterValues("chkValue");
      System.out.println(columns.length);
      analyticsService.ynTo10(columns);
  
      return "redirect:/analytics/info/1";
  }
  
  
  @RequestMapping(value="/nulltoN", method=RequestMethod.POST)
  public String nulltoN(HttpServletRequest req) {
  
      String[] columns = req.getParameterValues("chkColnames");
      analyticsService.nullToN(columns);
  
      return "redirect:/analytics/info/1";
  }
  </code></pre>
  
  <p>This is an attempt to call the controller with ajax according to the radio button selection.</p>
  
  <pre><code>$('#convert').click(function() {
      var chkVal = [];
      $('input[name=chkColnames]:checked').each(function() {
          chkVal = $(this).val();
      });
  
          if($('#ynTo10:selected')) {
            $.ajax({
                type: 'POST',
                url: 'http://localhost:8080/destiny/ynto10',
                data: {
                    chkValue : chkVal
                },
                dataType: 'json',
                success: alert('변환 OK'),
  
  
            })
        }else if($('#nullToN:selected')) {
            $.ajax({
                type: 'POST',
                url: 'http://localhost:8080/destiny/nulltoN',
                data: {
                    chkValue : chkVal
                },
                dataType: 'json',
                success: alert('변환 OK'),
  
            })
        }
  </code></pre>
  
  <p>And I would like to add a checkbox to the variable named chkVal. I would appreciate it if you could give me this part. Have a nice day.</p>