2015/10/25 using bootstrap Selectpicker to implement drop-down lists with fuzzy queries

Source: Internet
Author: User

Today's time is more relaxed, just tidy up their use of this two days a small plug-in function, do not involve too wide, just for their own better understanding.

Implementation features: Drop-down list shows people list, support input keywords for fuzzy query (People list through database query)
1. Java code: Controller
@RequestMapping (value = "List.do", method = Requestmethod.get)
Public Modelandview Listuser () {
Modelandview Mav = new Modelandview ("url");
Here is just an interface call, the implementation of the background through Hibernate query database, return to the employee list, Employeequerybean is a query condition bean
list<employee> queryemployeebyqueryparams = employeeservice.queryemployeebyqueryparams (New EmployeeQueryBean ());
Mav.addobject ("result", queryemployeebyqueryparams);
return MAV;
}

2. JSP
Introduced plugins: <script type= "text/javascript" src = ". /bootstrap-select/js/defaults-zh_cn.js "/>

<script type= "text/javascript" src = ". /bootstrap-select/js/bootstrap-select.js "/>

<script type= "text/javascript" src = ". /bootstrap-select/css/bootstrap-select.css "/>

<div class = "Form-group" >
The Col-xs-2:bootstrap grid system divides the page into 12 columns, where the number is used to specify the width
<label class = "Col-xs-2 control-lable" > People list:</label>
<div class = "Col-xs-5" >
Selectpicker: This is the use of a bootstrap drop-down plugin
Data-live-search: Set to find input box
<select name = "User" class = "Form-control selectpicker show-tick" Data-live-search = "true" >
Jstl here uses a Foreach loop to dynamically read the data returned by the database and then dynamically add options
<c:foreach items = "${result}" var = "Co" >
<option value = "${co.id}" >${co.name}</option>
</c:forEach>
</div>
</div>

3. js file
$ (function () {
Start Bootsrap-select
$ (". Selectpicker"). Selectpicker ({
Dropuauto:false
});
})

2015/10/25 using bootstrap Selectpicker to implement drop-down lists with fuzzy queries

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.