无法显示名称的自动填充功能

时间:2013-10-20 14:16:57

标签: jquery jsp struts2

我想在jsp页面中将名称显示为自动完成。我在行动中设置了一个名单,并希望将其视为我姓名文本框的自动完成列表。 我正在尝试以下链接的帮助 http://jqueryui.com/autocomplete/#remote

我的代码是

在jsp中

<html>
<head>
 <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <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>
</head>
<body>
 <div class="box">
                <span class="label">Names</span>
                <span class="ib"> <input type="text" name="name" id="name"/></span>
            </div>
<script>
                $('#name').autocomplete({
                    source: "test"
                });
   </script>
</body>
</html>

在struts.xml中

 <action name="test" class="iland.supplier.SupplierAction" method="test">
            <result  type="json"></result>
        </action>
在SupplierAction中

public String test() {
        ArrayList<String> sss = new ArrayList<String>();
        sss.add("Manish");
        sss.add("Manoj");
        sss.add("Mohan");
        sss.add("Madhuri");
        sss.add("Mayank");
        sss.add("Mitesh");
        sss.add("Mitali");
        setNames(sss);
        for (String s : sss) {
            System.out.println(" " + s);
        }

        return SUCCESS;
    }

点击名称文本框时,列表将在服务器控件上打印。

问题是我没有在jsp页面中获得自动完成列表

0 个答案:

没有答案