【发布时间】:2017-05-24 11:56:17
【问题描述】:
我正在使用 JSTL 和 Jquery 将数据自动完成,数据列表将从 Spring mvc 中的 List 获取
我的行动:
List<Map> mapList = googleMapLocationService.getAllGoogleMapLocations();
model.put("mapList", mapList);
jquery/jsp:
<script>
$( function() {
var availableTags =
<c:forEach items="${mapList}" var="map">
[
"<c:out value="${map.address}"/>"
];
</c:forEach>
$( "#tags" ).autocomplete({
source: availableTags
});
} );
<div style="width:320px ;margin-left: -38px; margin-top: -24px">
<input id="tags" path="tags" />
</div>
已更新:(尝试将 'address' 替换为 'id')
<script>
$( function() {
var availableTags = []
<c:forEach items="${mapList}" var="map">
availableTags.push("<c:out value="'${map.id}', "/>");
</c:forEach>
$( "#tags" ).autocomplete({
source: availableTags
});
} );
结果:
当我键入任何“关键字”时,它似乎无法在自动完成中列出
我该如何解决这个问题?非常感谢!
【问题讨论】:
标签: java jquery ajax spring-mvc jstl