title: How do I get information from a collection using Thymeleaf
body: <p>My controller looks like this:</p>
  
  <pre><code>@ModelAttribute("adminMenu")
  public Collection&lt;Menu&gt; getAdminMenu(HttpSession session, HttpServletRequest request) {
      Collection&lt;Menu&gt; menuCollection = this.stormfallService.findMenuByType("A", "A");
      log.debug("The collection for admin has " + menuCollection.size() + " records");
      session.setAttribute("adminMenu", menuCollection);
      /*Menu menu;
      Iterator&lt;Menu&gt; itr = menuCollection.iterator();
      while (itr.hasNext()) {
          menu = (Menu)itr.next();
          log.debug("The id = " + menu.getId());
          log.debug("The menu text is " + menu.getMenuText());
          log.debug("The menu type is " + menu.getMenuType());
          log.debug("The menu url is " + menu.getMenuUrl());
          log.debug("The menu sort order is " + menu.getSortOrder());
          log.debug("The menu status is " + menu.getStatus());
      }*/
  
      return menuCollection;
      //return null;
  }
  </code></pre>
  
  <p>I assume this is correct, but if not, tell me what it should be.</p>
  
  <p>My fragment looks like this:</p>
  
  <pre><code>&lt;div th:fragment="sidebar" class="sidebar" id="textbar"&gt;
      &lt;h4&gt;Admin Functions&lt;/h4&gt;
              &lt;ul class="menu"&gt;
                      &lt;!-- li th:each="menu,rowStat : ${adminMenu}" --&gt;
                      &lt;li th:each="menu,rowStat : #{session.adminMenu}"&gt;
                      &lt;a href="#" th:href="${menu.menuUrl}" th:text="${menu.menuText}"&gt;Some Admin Text&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
      &lt;h4&gt;User Functions&lt;/h4&gt;
              &lt;ul class="menu"&gt;
                      &lt;!-- li th:each="menu,rowStat : ${userMenu}" --&gt;
                      &lt;li th:each="menu,rowStat : #{session.userMenu"&gt;
                      &lt;a href="#" th:href="${menu.menuUrl}" th:text="${menu.menuText}"&gt;Some User Text&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
      &lt;h4&gt;Tools&lt;/h4&gt;
              &lt;ul class="menu"&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Change Password&lt;/a&gt;&lt;/li&gt;
                  &lt;li&gt;&lt;a href="#"&gt;Logout&lt;/a&gt;&lt;/li&gt;
              &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When I wasn't using the session, the commented out code builds the menu, but then when it goes to other pages, the menu disappears.  So it needs to be in the session.</p>
  
  <p>I get the following error with this new code:</p>
  
  <p>HTTP Status 500 - Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "menu.menuUrl" (layout:141)</p>
  
  <p>type Exception report</p>
  
  <p>message Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "menu.menuUrl" (layout:141)</p>
  
  <p>description The server encountered an internal error that prevented it from fulfilling this request.</p>
  
  <pre><code>exception
  
  org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "menu.menuUrl" (layout:141)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:948)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  
  root cause
  
  org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating SpringEL expression: "menu.menuUrl" (layout:141)
      org.thymeleaf.spring3.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:153)
      org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:149)
      org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:59)
      org.thymeleaf.standard.expression.Expression.execute(Expression.java:103)
      org.thymeleaf.standard.expression.Expression.execute(Expression.java:133)
      org.thymeleaf.standard.expression.Expression.execute(Expression.java:120)
      org.thymeleaf.standard.processor.attr.AbstractStandardSingleAttributeModifierAttrProcessor.getTargetAttributeValue(AbstractStandardSingleAttributeModifierAttrProcessor.java:67)
      org.thymeleaf.spring3.processor.attr.SpringHrefAttrProcessor.getTargetAttributeValue(SpringHrefAttrProcessor.java:68)
      org.thymeleaf.processor.attr.AbstractSingleAttributeModifierAttrProcessor.getModifiedAttributeValues(AbstractSingleAttributeModifierAttrProcessor.java:59)
      org.thymeleaf.processor.attr.AbstractAttributeModifierAttrProcessor.processAttribute(AbstractAttributeModifierAttrProcessor.java:61)
      org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87)
      org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)
      org.thymeleaf.dom.Node.applyNextProcessor(Node.java:973)
      org.thymeleaf.dom.Node.processNode(Node.java:928)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.Document.process(Document.java:93)
      org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1155)
      org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)
      org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)
      org.thymeleaf.spring3.view.ThymeleafView.renderFragment(ThymeleafView.java:335)
      org.thymeleaf.spring3.view.ThymeleafView.render(ThymeleafView.java:190)
      org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
      org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  
  root cause
  
  org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 5): Field or property 'menuUrl' cannot be found on object of type 'java.lang.String'
      org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:246)
      org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:112)
      org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:43)
      org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:87)
      org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:82)
      org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:93)
      org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:94)
      org.thymeleaf.spring3.expression.SpelVariableExpressionEvaluator.evaluate(SpelVariableExpressionEvaluator.java:138)
      org.thymeleaf.standard.expression.VariableExpression.executeVariable(VariableExpression.java:149)
      org.thymeleaf.standard.expression.SimpleExpression.executeSimple(SimpleExpression.java:59)
      org.thymeleaf.standard.expression.Expression.execute(Expression.java:103)
      org.thymeleaf.standard.expression.Expression.execute(Expression.java:133)
      org.thymeleaf.standard.expression.Expression.execute(Expression.java:120)
      org.thymeleaf.standard.processor.attr.AbstractStandardSingleAttributeModifierAttrProcessor.getTargetAttributeValue(AbstractStandardSingleAttributeModifierAttrProcessor.java:67)
      org.thymeleaf.spring3.processor.attr.SpringHrefAttrProcessor.getTargetAttributeValue(SpringHrefAttrProcessor.java:68)
      org.thymeleaf.processor.attr.AbstractSingleAttributeModifierAttrProcessor.getModifiedAttributeValues(AbstractSingleAttributeModifierAttrProcessor.java:59)
      org.thymeleaf.processor.attr.AbstractAttributeModifierAttrProcessor.processAttribute(AbstractAttributeModifierAttrProcessor.java:61)
      org.thymeleaf.processor.attr.AbstractAttrProcessor.doProcess(AbstractAttrProcessor.java:87)
      org.thymeleaf.processor.AbstractProcessor.process(AbstractProcessor.java:212)
      org.thymeleaf.dom.Node.applyNextProcessor(Node.java:973)
      org.thymeleaf.dom.Node.processNode(Node.java:928)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.NestableNode.computeNextChild(NestableNode.java:654)
      org.thymeleaf.dom.NestableNode.doAdditionalProcess(NestableNode.java:637)
      org.thymeleaf.dom.Node.processNode(Node.java:947)
      org.thymeleaf.dom.Document.process(Document.java:93)
      org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1155)
      org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1060)
      org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1011)
      org.thymeleaf.spring3.view.ThymeleafView.renderFragment(ThymeleafView.java:335)
      org.thymeleaf.spring3.view.ThymeleafView.render(ThymeleafView.java:190)
      org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1208)
      org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
      org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
      org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
      org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
      org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
      org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
      org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
  
  note The full stack trace of the root cause is available in the Apache Tomcat/7.0.42 logs.
  Apache Tomcat/7.0.42
  </code></pre>
  
  <p>Any help would be appreciated.</p>