title: Java List to Thymeleaf Form Inputs
body: <p>I have a list in Java from a query of a stored procedure, what I want to do is pass the values ​​of the list, to the inputs of the thymeleaf form, but I want to know how to pass that list in the controller and iterate it in the view, It is a Boostrap Modal, I would like help if I could do it with Ajax or with the th: fragment of thymeleaf.</p>
  
  <p><strong>Model function</strong></p>
  
  <pre><code>public List getTypePlan(int id){
          List type = new ArrayList&lt;&gt;();
          try {
              Connection conn = AppConnection.getConnection();
              CallableStatement cstmt = conn.prepareCall("{call SP_LEER_PFI_TIPOS_PLANES(?)}");
              cstmt.setInt(1, id);
              ResultSet results = cstmt.executeQuery();
              while (results.next()) {
                  int cod_plan = results.getInt("cod_plan");
                  String des_plan = results.getString("des_plan");
                  int can_dias_plazo = results.getInt("can_dias_plazo");
                  type.add(cod_plan);
                  type.add(des_plan);
                  type.add(can_dias_plazo);
              }
              conn.close();
          } catch (SQLException ex) {
          }
          return type;
      }
  </code></pre>
  
  <p><strong><em>Output example:</em></strong> <code>[1,General,3]</code></p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>@RequestMapping(value="/typePlan/{id}", method = RequestMethod.GET)
      public String typePlan(@PathVariable("id") int id, Model m){
          Users_Access model = new Users_Access();
          m.addAttribute("type", model.getTypePlan(id));
          return "home :: type";
      }
  }
  </code></pre>
  
  <p><strong>Boostrap Modal form</strong></p>
  
  <pre><code>&lt;div class="modal fade" data-keyboard="false" data-backdrop="static" id="TiposPlanes" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true"&gt;
      &lt;div class="modal-dialog modal-dialog-centered" role="document"&gt;
        &lt;div class="modal-content"&gt;
          &lt;div class="modal-header"&gt;
            &lt;h5 class="modal-title"&gt;TIPOS DE PLANES&lt;/h5&gt;
              &lt;button type="button" class="close" data-dismiss="modal" aria-label="Close"&gt;
                &lt;span aria-hidden="true"&gt;&amp;times;&lt;/span&gt;
              &lt;/button&gt;
          &lt;/div&gt;
          &lt;div class="modal-body"&gt;
            &lt;div class="modal-bodyh"&gt;
              &lt;h6 class="modal-subtitle"&gt;&lt;i class="fas fa-pencil-alt"&gt;&lt;/i&gt;  MODIFICAR TIPOS DE PLANES&lt;/h6&gt;
              &lt;h6 class="modal-subtitle"&gt;Presione click en el boton Modificar para grabar los cambios&lt;/h6&gt;
            &lt;/div&gt;
            &lt;div class="modal-form" th:fragment="type"&gt;
              &lt;form class="form" th:method="post"&gt;
                &lt;div class="form-group"&gt;
                  &lt;label class="col-form-label"&gt;Codigo:&lt;/label&gt;
                  &lt;input type="text" class="form-control" id="codigo" name="codigo"&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;label class="col-form-label"&gt;Descripcion:&lt;/label&gt;
                  &lt;input type="text" class="form-control" id="descripcion" name="descripcion"&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;label class="col-form-label"&gt;Diaz plazo:&lt;/label&gt;
                  &lt;input type="text" class="form-control" id="dias" name="dias"&gt;
                &lt;/div&gt;
                &lt;div class="form-group"&gt;
                  &lt;button type="button" class="btn btn-primary" value="save"&gt;Modificar&lt;/button&gt;
                  &lt;button type="button" class="btn btn-primary" data-dismiss="modal"&gt;Cancelar&lt;/button&gt;
                &lt;/div&gt;
              &lt;/form&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  </code></pre>