jquery-ui-custom autocomplete
//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 "a"">
</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的更多相关文章
- 弹窗中使用jquery ui的autocomplete自动完成插件无效果 实际是被遮挡了
在普通页面上使用jquery ui的autocomplete自动完成插件时正常显示提供选择的下拉框,但是放到弹窗中的时候就无法显示这个选择的下拉框,其它效果正常: 估计是被弹出窗遮挡了,网络搜索了jq ...
- ASP.NET jQuery 随笔 使用jQuery UI的Autocomplete方法实现文本框的自动搜索填充功能
首先当然是去下载JQuery UI ,这里这里是下载地址http://jqueryui.com/ 第一步是点击这里 第二步选择你想要下载的主题进行下载 我这里是选择的cupertino主题包 点击圆圈 ...
- Jquery UI Custom的兼容问题
在测试过程中遇到Jquery UI Dialog异常的情况,表现为在拖拽Dialog标头时出现Dialog跳跃的问题,对比jquery ui与jquery在协调工作情况下的运行情况. 1.环境: Wi ...
- JQuery UI之Autocomplete(4)多值输入、远程缓存与组合框
1.多值输入 首先加入相关的css和js文件,以及对应的HTML代码如下: <link href="../css/jquery-ui.css" rel="style ...
- JQuery UI之Autocomplete(3)属性与事件
1.Autocomplete的属性 首先引入css和js文件,以及对应的HTML代码如下: <link href="../css/jquery-ui.css" rel=&qu ...
- JQuery UI之Autocomplete(1)入门程序
1.Autocomplete的主要属性:source:即为指定智能提示下拉框中的数据来源,支持三种类型. Array,主要用于本地化数据提供,支持两种格式:字符串数组 [ "Choice1 ...
- JQuery UI之Autocomplete(2)后端获取数据
1.Autocomplete获取后台数据 首先引入css和js文件,以及对应的HTML代码如下: <link href="../css/jquery-ui.css" rel= ...
- Node.js配合jQuery UI autocomplete的应用
Node.js擅长的领域为: 不需要很多运算 吞吐量要求高 进消息轻并且要求快 出消息轻并且要求快 网上的例子都是socket.io的,我一直在想到底能用在什么地方?根据node.js的优点(擅长领域 ...
- jQuery ui autocomplete下拉列表样式失效解决,三种获取数据源方式,
jQuery有很多很多的已经实现,很漂亮的插件,autocomplete就是其中之一.jQuery ui autocomplete主要支持字符串Array.JSON两种数据格式,jQuery ui b ...
- JQuery UI Autocomplete与jquery.autocomplete.js
程序中要把一个select改成可以下拉搜索的,就想到了使用下autocomplete.js大概是这么个东西. 问了下同学,推荐我使用Jquery Ui autocomplete,下载下来开始调试使用, ...
随机推荐
- angularjs string format
用惯了C#的string.format,在angularjs中还不太习惯字符串的拼接,还好可以自定义String.Format String.format = function() { ) retur ...
- Swift-取消传统For循环
1.取消传统的For循环 传统的for,在swift 3.0 被取消 i++/++i在swift 3.0 被取消 i += 1代替 for var i = 0;i<10;i +=1 { } 2. ...
- intellijidea课程 intellijidea神器使用技巧 3-3 postfix
Ctrl shift A ==> postfix completion 调出postfix 方法体中 ==> for 100.fori ==>enter for循环10 ...
- Redis数据类型之散列类型hash
在redis中用的最多的就是hash和string类型. 问题 假设有User对象以JSON序列化的形式存储到redis中, User对象有id.username.password.age.name等 ...
- Cookie存储大小、个数限制
一.浏览器允许每个域名所包含的cookie数: Microsoft指出InternetExplorer8增加cookie限制为每个域名50个,但IE7似乎也允许每个域名50个cookie. Firef ...
- rem与em的区别
这两个单位都是相对元素 rem相对根元素 em相对于父级元素
- ActionMethod_DMI_动态方法调用
Action执行的时候并不一定要执行execute方法可以在配置文件中配置Action的时候用method=来指定执行那个方法,也可以在url地址中动态指定(动态方法调用DMI)(推荐) 动态方法调用 ...
- 被遗忘的设计模式——空对象模式(Null Object Pattern)
GoF(四人帮)那本<设计模式 可复用面向对象软件的基础>可谓是设计模式方面的经典之作,其中介绍的23种设计模式, 也可谓是经典中的经典.但是,设计模式的种类绝不仅仅是这23种,除此之外还 ...
- constrained属性
hibernate文档上是这么写的: constrained(约束) (可选) 表明该类对应的表对应的数据库表,和被关联的对象所对应的数据库表之间,通过一个外键引用对主键进行约束.这个选项影响save ...
- OpenCart-2.3 (Ubuntu 16.04)
平台: Ubuntu 类型: 虚拟机镜像 软件包: opencart-2.3 commercial ecommerce opencart open-source 服务优惠价: 按服务商许可协议 云 ...