//jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort()+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <base href="<%=basePath%>">
 
        <title>autocomplete</title>
 
        <meta http-equiv="pragma" content="no-cache">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="0">
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="This is my page"> 
  
        <link href="<%=basePath%>js/autocomplete/jquery-ui-1.10.3.custom.css" rel="stylesheet">
        <script src="<%=basePath%>js/jquery-1.7.2.min.js"></script>
        <script src="<%=basePath%>js/autocomplete/jquery-ui-1.10.3.custom.js"></script>
    <script>
        $(function(){
            $( "#autocomplete" ).autocomplete({
                minLength: 1,//最少输入1个字符才执行
                source: 'autocomplete.action'
            });
        })
    </script>
    </head>
    <style>
        body {
            font: 62.5% "Trebuchet MS", sans-serif;
            margin: 50px;
        }
    </style>
    <body>
        <h2 style="margin-top: 2em;">
            Autocomplete
        </h2>
        <div>
            <input id="autocomplete" title="type &quot;a&quot;">
        </div>
    </body>
</html>  
//struts.xml
<action name="autocomplete" class="com.test.action.testAction" method="autocomplete"></action>

//java
public String autocomplete() throws Exception{
         
        String[] temp = "align,both,card,dream,error,fail,gson,hello,invaid,job,kill".split(",");
        String name = "[";
        for(int i=0;i<temp.length;i++){
            if(temp[i].indexOf(term)!=-1){
                name += "\""+temp[i]+"\",";
            }
        }
        if(name.length() > 1)
            name = name.substring(0,name.length()-1);
        name+="]";
         
        System.out.println(name);
         
        HttpServletResponse res = ServletActionContext.getResponse();
        PrintWriter pw = res.getWriter();
        pw.write(name);
        pw.flush();
        pw.close();
         
        return null;
    }

jquery-ui-custom autocomplete的更多相关文章

  1. 弹窗中使用jquery ui的autocomplete自动完成插件无效果 实际是被遮挡了

    在普通页面上使用jquery ui的autocomplete自动完成插件时正常显示提供选择的下拉框,但是放到弹窗中的时候就无法显示这个选择的下拉框,其它效果正常: 估计是被弹出窗遮挡了,网络搜索了jq ...

  2. ASP.NET jQuery 随笔 使用jQuery UI的Autocomplete方法实现文本框的自动搜索填充功能

    首先当然是去下载JQuery UI ,这里这里是下载地址http://jqueryui.com/ 第一步是点击这里 第二步选择你想要下载的主题进行下载 我这里是选择的cupertino主题包 点击圆圈 ...

  3. Jquery UI Custom的兼容问题

    在测试过程中遇到Jquery UI Dialog异常的情况,表现为在拖拽Dialog标头时出现Dialog跳跃的问题,对比jquery ui与jquery在协调工作情况下的运行情况. 1.环境: Wi ...

  4. JQuery UI之Autocomplete(4)多值输入、远程缓存与组合框

    1.多值输入 首先加入相关的css和js文件,以及对应的HTML代码如下: <link href="../css/jquery-ui.css" rel="style ...

  5. JQuery UI之Autocomplete(3)属性与事件

    1.Autocomplete的属性 首先引入css和js文件,以及对应的HTML代码如下: <link href="../css/jquery-ui.css" rel=&qu ...

  6. JQuery UI之Autocomplete(1)入门程序

    1.Autocomplete的主要属性:source:即为指定智能提示下拉框中的数据来源,支持三种类型.  Array,主要用于本地化数据提供,支持两种格式:字符串数组 [ "Choice1 ...

  7. JQuery UI之Autocomplete(2)后端获取数据

    1.Autocomplete获取后台数据 首先引入css和js文件,以及对应的HTML代码如下: <link href="../css/jquery-ui.css" rel= ...

  8. Node.js配合jQuery UI autocomplete的应用

    Node.js擅长的领域为: 不需要很多运算 吞吐量要求高 进消息轻并且要求快 出消息轻并且要求快 网上的例子都是socket.io的,我一直在想到底能用在什么地方?根据node.js的优点(擅长领域 ...

  9. jQuery ui autocomplete下拉列表样式失效解决,三种获取数据源方式,

    jQuery有很多很多的已经实现,很漂亮的插件,autocomplete就是其中之一.jQuery ui autocomplete主要支持字符串Array.JSON两种数据格式,jQuery ui b ...

  10. JQuery UI Autocomplete与jquery.autocomplete.js

    程序中要把一个select改成可以下拉搜索的,就想到了使用下autocomplete.js大概是这么个东西. 问了下同学,推荐我使用Jquery Ui autocomplete,下载下来开始调试使用, ...

随机推荐

  1. 性能测试工具LoadRunner03-LR之Virtual User Generator 脚本创建以及回放设置

    vuser_init,Action,vuser_end说明 vuser_init 录制的一般是业务流程开始之前的初始化工作(如登录,服务器初始化) Action 录制的一般是业务流程操作的事件 vus ...

  2. [转]jQueryUI中Datepicker(日历)插件的介绍和使用

    http://jqueryui.com/datepicker/ 本文转自:http://blog.csdn.net/redarmy_chen/article/details/7400571 jQuer ...

  3. (转)Shell脚本编程--Uniq命令

    uniq 原文:http://blog.csdn.net/xifeijian/article/details/9209627 uniq命令可以去除排序过的文件中的重复行,因此uniq经常和sort合用 ...

  4. php fopen()和file_get_contents() 区别介绍

    本文章向码农们介绍PHP使用fopen与file_get_contents读取文件实例分享及这两个函数的区别,需要的码农可以参考一下. php中读取文件可以使用fopen和file_get_conte ...

  5. kafka brokers配置参数详解

    基本配置如下: -broker.id-log.dirs-zookeeper.connect Topic-level配置以及其默认值将在下面讨论. Property Default Descriptio ...

  6. ASP.NET 4.5 尚未在 Web 服务器上注册。您需要手动将 Web 服务器配置为使用 ASP.NET 4.5,这样您的网站才能正确运行。

    系统换成Windows10安装VS2012打开项目总提示:vs2012 aps.NET 4.5尚未在web服务器上注册,您需要手动将Web服务器配置为使用ASP.Net 4.5,这样您的网站才可能正确 ...

  7. spring boot Configuration Annotation Proessor not found in classpath

    出现spring boot Configuration Annotation Proessor not found in classpath的提示是在用了@ConfigurationPropertie ...

  8. spring mvc 与Struts的认识

    首先,纠正一个概念上的错误.ssh一般意义上是指 struts,spring framework以及hibernate.这三个框架作用是不一样的.hibernate主要是用于持久层,struts主要是 ...

  9. three.js学习笔记--基础知识

    基础知识 从去年开始就在计划中的three.js终于开始了 历史介绍 (摘自ijunfan1994的转载,感谢作者) OpenGL大概许多人都有所耳闻,它是最常用的跨平台图形库. WebGL是基于Op ...

  10. PHP underlying structure

    http://www.phpinternalsbook.com/classes_objects/magic_interfaces_comparable.html