title: How to get data from List in JSTL with autocomplete spring mvc
body: <p>I'm using JSTL and Jquery to get data into autocomplete, list of data will get from List in Spring mvc</p>
  
  <p>My action:</p>
  
  <pre><code>List&lt;Map&gt; mapList = googleMapLocationService.getAllGoogleMapLocations();
  model.put("mapList", mapList);
  </code></pre>
  
  <p>jquery/jsp:</p>
  
  <pre><code>&lt;script&gt;
    $( function() {
    var availableTags =
        &lt;c:forEach items="${mapList}" var="map"&gt;
        [         
            "&lt;c:out value="${map.address}"/&gt;"         
        ];
        &lt;/c:forEach&gt;
    $( "#tags" ).autocomplete({
      source: availableTags
    });
   } );
  </code></pre>
  
  <p></p>
  
  <pre><code>  &lt;div style="width:320px ;margin-left: -38px; margin-top: -24px"&gt;
      &lt;input id="tags" path="tags" /&gt;
    &lt;/div&gt;
  </code></pre>
  
  <p>UPDATED: (try to replace 'address' is 'id')</p>
  
  <pre><code>&lt;script&gt;
  $( function() {
  var availableTags = []
      &lt;c:forEach items="${mapList}" var="map"&gt;
          availableTags.push("&lt;c:out value="'${map.id}', "/&gt;");
      &lt;/c:forEach&gt;
   $( "#tags" ).autocomplete({
     source: availableTags
   });
  } );
  </code></pre>
  
  <p></p>
  
  <p>RESULT:</p>
  
  <p><a href="https://i.stack.imgur.com/lxgNg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lxgNg.png" alt="enter image description here"></a></p>
  
  <p>When I type a 'keyword' any, it seem can not list on autocomplete</p>
  
  <p>How can I fix the problem ? Thank so much !</p>