[英]Jquery/Spring: Why doesn't my autocomplete work when I try to pass in source using @ResponseBody?
My autocomplete always displays all the variables in my data source for some reason. 由于某种原因,我的自动完成功能始终显示数据源中的所有变量。 Anyone know the problem?
有人知道这个问题吗?
My index.jsp 我的index.jsp
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
$(function () {
$("#streamers").autocomplete({
source: '${pageContext.request.contextPath}/getStreamerList'
});
});
</script>
<div class="ui-widget">
Streamer:
<input id="streamers" type="text" name="streamerName" value=${fn:escapeXml(param.streamerName)}>
</div>
My controller: 我的控制器:
@RequestMapping(value = {"/getStreamerList"}, method = RequestMethod.GET)
public
@ResponseBody
List<String> getStreamerList() {
List<String> list = new ArrayList<String>();
list.add("TEST");
list.add("BOB");
return list;
}
TEST and BOB basically shows up on autocomplete no matter what I type, like "est" 无论输入什么类型,例如“ est”,TEST和BOB基本上都会显示在自动完成功能上
nvm this is intended behavior. nvm这是预期的行为。 I'm supposed to filter the results on the server side according to jquery API.
我应该根据jquery API在服务器端过滤结果。
have you put Jackson JSON in your class path use following cordinates for maven project 您是否将Jackson JSON放在类路径中,对Maven项目使用以下坐标
<!-- Jackson JSON Mapper -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson.version}</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.