title: EL1012E: Cannot index into a null value
body: <p>I have this piece of code in a Thymeleaf template</p>
  <pre><code>var theList = /*[[${route}]]*/
  
  for (i = 0; i &lt; theList.length; i++) {
      var coordinate = [ /*[[${theList[i].longitude}]]*/ , /*[[${theList[i].latitude}]]*/ ];
      coordinates2.push(coordinate);
  }
                          
  </code></pre>
  <p>when the object <code>${route}</code> is not null, but an empty List that I pass through the controller:</p>
  <pre><code>List&lt;Coordinate&gt; route = new ArrayList&lt;Coordinate&gt;();
  model.addAttribute(&quot;route&quot;, route);
  </code></pre>
  <p>I get this error:</p>
  <pre><code>org.springframework.expression.spel.SpelEvaluationException: EL1012E: Cannot index into a null value
      at org.springframework.expression.spel.ast.Indexer.getValueRef(Indexer.java:132)
      at org.springframework.expression.spel.ast.Indexer.getValueInternal(Indexer.java:89)
      at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:57)
      at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:87)
      at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:121)
      at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:324)
  </code></pre>