title: Retrieve data from ModelAttribute method in the view
body: <p>In my current spring project, I have a generic controller like this:</p>
  
  <pre><code>public class basicController&lt;E&gt; {
    @Autowired
    private basicService&lt;E&gt; serv;
  
    protected Class&lt;?&gt; clazz;
  
    public basicController(Class&lt;?&gt; clazz) {
      this.clazz = clazz;
    }
  
    ...
  
  }
  </code></pre>
  
  <p>with a method like this:</p>
  
  <pre><code>  @ModelAttribute("lista")
    public List&lt;E&gt; populateList() {
      return serv.lista();
    }
  </code></pre>
  
  <p>I wonder if it's possible use the value for <code>lista</code> in a structure like that (in the html page):</p>
  
  <pre><code>&lt;select class="form-control" th:name="..."&gt;
      &lt;option th:each="opt : ${lista}" th:value="${opt.getId()}"&gt;&lt;span th:text="${opt}"/&gt;
      &lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>this page is mapped in the controllers with methods like that:</p>
  
  <p><strong>generic controller</strong></p>
  
  <pre><code>  @RequestMapping(value = "cadastra")
    @PreAuthorize("hasPermission(#user, 'cadastra_'+#this.this.name)")
    @Menu(label = "cadastra")
    public String cadastra(Model model) throws Exception {
      model.addAttribute("command", serv.newObject());
      return "private/cadastra";
    }
  </code></pre>
  
  <p><strong>home controller (contains mappings for public views, among others things)</strong></p>
  
  <pre><code>  @RequestMapping(value = "/settings")
    public String settings(Model model) throws Exception {
      Authentication auth = SecurityContextHolder.getContext().getAuthentication();
      model.addAttribute("usuario", auth.getName());
      model.addAttribute("menu", MenuList.index());
      model.addAttribute("settings", MenuList.settings());
      return "private/settings";
    }
  
    @RequestMapping(value = "/profile")
    public String profile(Model model) throws Exception {
      Authentication auth = SecurityContextHolder.getContext().getAuthentication();
      model.addAttribute("usuario", auth.getName());
      model.addAttribute("menu", MenuList.index());
      model.addAttribute("command", usuario(auth.getName()));
      return "private/profile";
    }
  </code></pre>
  
  <p>Anyone have any idea about this?</p>