简体   繁体   English

jQuery / Spring:当我尝试使用@ResponseBody传递源代码时,为什么我的自动填充功能无法正常工作?

[英]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.

相关问题 在Spring 3中使用@ResponseBody返回对象不起作用 - Returning object using @ResponseBody with spring 3 doesn't work 为什么注释 @ResponseBody 以及返回值“ModelAndView”不起作用? - Why the annontation @ResponseBody along with the return value 'ModelAndView' doesn't work? 为什么使用BigDecimal时我的操作不起作用? - Why doesn't my operation work when I use BigDecimal? 我尝试在开始之前准备我的媒体播放器按钮,但是当我单击它时它不起作用 - I try to prepare my mediaplayer button before start, but it doesn't work when i clicked on it 为什么我的try catch语句不起作用? - Why doesn't my try catch statement work? 当我尝试查看它的版本并创建应用程序时,为什么 Grails 2.4.5 版本不起作用? - Why doesn't Grails 2.4.5 version work when I try to see it's version and create a Application? 我尝试编写自己的 makefile 但它不起作用 - I try to write my own makefile but it doesn't work 我的休眠映射文件未通过验证测试,尝试运行该程序时出现异常。为什么? - My hibernate mapping file doesn't pass the validation test and I get an exception as I try to run the program.Why is that? 为什么 intellij 代码自动完成功能不起作用? - Why the intellij code autocomplete doesn't work? 当我尝试运行我的程序时,视图无法打开? - View Doesn't Open When I Try To Run My Program?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM