标签:i18n dao src mapping 取整 获取信息 asc ext roc
<link href="${ctxStatic}/jquery-select2/4.0.3/select2.min.css" rel="stylesheet" />
<script src="${ctxStatic}/jquery-select2/4.0.3/select2.full.min.js" type="text/javascript"></script>
<script src="${ctxStatic}/jquery-select2/4.0.3/i18n/zh-CN.js" type="text/javascript"></script>
$("[data-toggle=‘tooltip‘]").tooltip({html: true});
//获取整个列表
$(‘#primaryAuditUserId‘).select2({
language: "zh-CN",
minimumInputLength: 1,
placeholder: "-- 请输入昵称搜索 --",
ajax: {
url: "xxx/xxx/xxxx/userAll",
dataType: "json",
delay: 500,
data: function (params) {
return {name: params.term};//name为入参标识
},
processResults: function (res, params) {
var options = [];
console.log("res:"+res);
$(res).each(function (index, r) {
var option = {"id": r.id, "text": r.name};//列表中的id,列表中的name
options.push(option);
});
return {
results: options
};
},
escapeMarkup: function (m) {
return m;
}
}
});
//获取ID
(function () {
var id = $("#select2-userId").val();
if (id) {
$.get("xxxxxx/xxxx/single/" + id, function (result) {
if (result) {
$("#primaryAuditUserId").html("<option value=‘" + result.id + "‘>" + result.name + "</option>");//
}
});
}
})();
<li>
<label>初审人:</label>
<input type="hidden" id="select2-userId" value="${infoDto.primaryAuditUserId}"/>
<form:select path="primaryAuditUserId" class="input-medium"></form:select>
</li>
接口:
//模糊匹配列表
@RequestMapping(value="userAll")
@ResponseBody
public List<User> getUsers(String name){
User user=new User();
user.setDelFlag("0");
user.setName(name);
List<User> userList=userDao.findList(user);
if(userList.size()<=0||userList==null){
return null;
}
return userList;
}
//查询单个的id
@RequestMapping(value="singUser")
@ResponseBody
public String getSingleUser(String name){
User user=new User();
user.setName(name);
User user_=userDao.getSingle(user);
return user_.getId();
}
标签:i18n dao src mapping 取整 获取信息 asc ext roc
原文地址:http://www.cnblogs.com/austinspark-jessylu/p/7220750.html