JQuery自动完成返回奇数值

时间:2011-04-12 06:25:52

标签: jquery json autocomplete

我的JQuery自动完成类型有效 - 它只返回一个列表,其中一行是 < - gt IE 9或类似的东西,否则是空的!

使用json是错误的输入,但是如何?

$(document).ready(function(){

    $("#field").autocomplete("page.html", {
        extraParams: {
            search: function() {
                return $("#field").val();
            }
        }
    });


 @RequestMapping(value="page.html", params = "search", method = RequestMethod.GET)
    public @ResponseBody String getUserAccounts(HttpServletRequest request,
                                                @RequestParam("search") String search) {
       if (search==null||search.matches(TuhaConstants.BADSTR)||search.length()<2||search.contains("*")) {
            // logger.debug("ajax.html getUserAccounts() bad parameters");
            return "";
        }
        logger.debug("page.html getUserAccounts() search param "+search);
        Details user = (Details) SecurityContextHolder.getContext().getAuthentication().getDetails();
        String selectedRole=(String)request.getSession().getAttribute("selected_role");
        Search se = new Search();
        se.setUserId(search+"*");
    List <Account> tuAccounts = ldapClient.getAccounts(user.getUser().getUid(), se, selectedRole);
        StringBuilder sb = new StringBuilder();
        int count=0;
        for(UtuAccount ua: tuAccounts) {
            if (!ua.getUid().matches(TuhaConstants.BADSTR)) {  
                sb.append(ua.getUid()).append("\n");
            }
            count++;
        }

        return sb.toString();

0 个答案:

没有答案