bootstrap仿百度输入框智能提示(提示信息存在于数据库中)

示例图片:

百度示例

bootstrap仿百度输入框智能提示(提示信息存在于数据库中)_第1张图片

所实现示例

bootstrap仿百度输入框智能提示(提示信息存在于数据库中)_第2张图片




jsp:





















js:

/**
 * 根据输入显示提示信息
 */
function autosearchCargono(){
$("#companyName").autocomplete({
minLength: 1,
source: function( request, response ) {
var term = request.term;
$.ajax({
url: "${base}/admin/road/billRecharge/getValue.do",
dataType: "json",
type:"post",
data:{
companyName: term
},
success: function( data ) {
response($.map( data, function( item ) {
$("#corpId").val(item.companyId)
return {
lable:item.companyId,
value:item.companyName
}
}));
}
});
}
});
}

controller 控制层:

@RequestMapping(value = "/getValue", method = RequestMethod.POST)
public @ResponseBody String getValue(String companyName){
return JSON.toJSONString(billRechargeService.getValue(companyName));
}

service 服务层:

@Override
public List getValue(String companyName) {
 return dbcCompanyBalanceMapper.getValue(companyName);
}

dao层:

List getValue(@Param("companyName")String companyName);


mapper.xml配置文件sql:



你可能感兴趣的:(js相关,mybatis)