JQueryとSpring 2.5.6を使ってオートコンプリートリストを表示しようとしているのですが、フロントエンドにjsonを入れているのですが表示できません。
$(function() {
$("#globalSearch").autocomplete({
source: function(request, response) {
$.ajax({
url: "${pageContext.request.contextPath}/autoSearch.htm",
data: {
term : request.term
},
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function(data) {
// this is the alert output its displaying:{"list":["ernst","ernst "]}
alert(JSON.stringify(data, null, 4));
response($.map(data, function(item) {
//its not alerting anything here
alert(JSON.stringify(item, null, 4));
return{
value: item.list
};
}));
}
});
}
});
});
ここに私の春のコントローラーコードがあります:
@RequestMapping(method = RequestMethod.GET, value = "/autoSearch.htm")
public ModelAndView autoSearch(
@RequestParam(value = "term", required = false) String term
) throws ParseException, IOException {
if (logger.isDebugEnabled()) {
logger.debug("inventoryHandler called");
}
Map<String, Object> model = new HashMap<String, Object>();
int i = 0;
model.put("list", getBaseModel().getSearchServiceBean().autoCompleter(term));
return new ModelAndView("jsonView", model);
}
オートコンプリート リストを表示する方法を教えてください。
前もって感謝します、
よろしく、ラジャ。