春季3,LDAP和查询自动填充文本字段 [英] Spring 3, ldap and Query autocomplete text field
问题描述
我想有我的春节,3表单上的autocompliting输入(文本)字段。建议值应该来自LDAP。我应该使用JQuery这一点,但到目前为止,这是我所知道的。我已经发现了一些实例与数据txt.files,但不是LDAP。
I would like to have an autocompliting input (text) field on my Spring 3 form. The suggested values should come from ldap. I should use JQuery for this, but so far that's all I know. I have found some examples with data txt.files, but not ldap.
推荐答案
创建一个servlet或控制器(例如 / getLdapData code>),这将获取从数据库和返回数据它作为字符串时
的'\\ n'
将值之间的分隔符:
Create a Servlet or Controller (for example /getLdapData
) which will fetch data from data base and return it as string when '\n'
will be separator between values:
然后为你创造控制自动完成:
Then create autocomplete for your control:
<script type="text/javascript">
$(document).ready(function(){
$("#ldapSearch").autocomplete('/getLdapData');
});
</script>
更新:
@RequestMapping(value ="/getLdapData",method= RequestMethod.GET)
@ResponseBody
public void getMaxRequestSize(HttpServletResponse response){
String autoCompleteList = null;
//List<String> ldapUsers is the list you fetched from LDAP.
ldapUsers = ldapService.getUserList();
Iterator itr = ldapUsers.iterator();
while(itr.hasNext()) {
autoCompleteList +=itr.next().toString() + "\n" ;
}
response.setContentType("text/html");
PrintWriter writer;
try {
writer = response.getWriter();
writer.write(autoCompleteList);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
我不知道究竟如何从LDAP用户列表中,但我认为的这篇文章可以给你正确的方向。
这篇关于春季3,LDAP和查询自动填充文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!