title: Spring MVC and Thymeleaf: How to get the value of an object of a list after an iteration
body: <p>Hi all and thank you for reading my issue.</p>
  
  <p>I'm programming an application using Spring MVC and Thymeleaf, and I have the following problem.</p>
  
  <p>I'm iterating a list of objects, and displaying a button under them using, and my goal is to update the database getting the value of one attribute from a specific iterated object, but the attribute retrieved is empty, and it'd should not be empty.</p>
  
  <p>My controller class:</p>
  
  <pre><code>@Controller
  @RequestMapping("/mostrar_usuarios")
  public class MostrarUsuariosController {
  
      private final UsuarioService usuarioService;
  
      @Autowired
      public MostrarUsuariosController(UsuarioService usuarioService) {
          this.usuarioService = usuarioService;
      }
  
      @RequestMapping(method = RequestMethod.GET)
      public String mostrarVista(ModelMap model, HttpSession session) {
          UsuarioVO u = (UsuarioVO) session.getAttribute("usuarioActivo");
          if (u != null) {
              ArrayList&lt;UsuarioVO&gt; listaUsuarios = (ArrayList&lt;UsuarioVO&gt;) this.usuarioService.retrieveAll();
              model.addAttribute("usuarios", listaUsuarios);
              return "mostrar_usuarios";
          } else {
              return "redirect:/paginaprincipal";
          }
      }
  
      @RequestMapping(method = RequestMethod.POST)
      public String registrarse(@ModelAttribute("usuario") UsuarioVO usuario, ModelMap model, HttpSession session) {
          UsuarioVO u = (UsuarioVO) session.getAttribute("usuarioActivo");
          if (u != null) {
              u.getSeguidos().add(usuario); // usuario comes empty
              this.usuarioService.update(u);
              return "mostrar_usuarios";
          } else {
              return "redirect:/paginaprincipal";
          }
      }
  }
  </code></pre>
  
  <p>Here is my html + thymeleaf code:</p>
  
  <pre><code>        &lt;div class="media-container-row" th:each="usuario: ${usuarios}"&gt;
              &lt;div class="title col-12 col-md-8"&gt;
                  &lt;br&gt;&lt;/br&gt;
                  &lt;hr /&gt;
                  &lt;br&gt;&lt;/br&gt;
                  &lt;h5 class="align-center pb-3 mbr-fonts-style display-2"
                      th:text="${usuario.nombre + ' @' + usuario.arroba}"
                      id="tamanioTexto"&gt;&lt;/h5&gt;
                  &lt;form class="align-center pb-3 mbr-fonts-style display-2" action="#" method="POST" th:object="${usuario}" id="tamanioPie"&gt;
                  &lt;button id="boton" type="submit"&gt;Seguir&lt;/button&gt;
                  &lt;/form&gt;
                  &lt;br&gt;&lt;/br&gt;
                  &lt;hr /&gt;
                  &lt;br&gt;&lt;/br&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  </code></pre>
  
  <p>All works fine, except the <code>th:object="${usuario}" #style it as code</code>, with what I want to get the specific iterated object, depending on the button clicked within the controller.</p>