Jsp+java the Drop-down box to read the database data __java

Source: Internet
Author: User

To implement a small function of the interface, the dropdown box reads the database information, displays it in the streets, clicks the selected value, and stores it in the database.


below look at the interface effect:




first, introduce the implementation of the following interface JSP code:

<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >			<div class= "Formitem" >
				<div class= "F_label" >
					<span class= "Red" >*</span> User name:
				</div>
				<div class= "F_item" ></span>
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >                                <!--This is the data that will be read from the database and displayed to the interface--></span>
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >					<input type= "text" id= "Realname" name= "Realname"/> <input type= "hidden" "Name=" Allotuuid "id=" 
					Allotuuid "/> <input type= hidden" id= "userid" name= "userid"  
					/>
				</div>
			</div></ Span>

Javascrip Implementation

<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >	$ (function () {	
		createselect (' Realname ', {
		valuefieldid: ' userid '), Get hidden field ID
		textField: ' Realname ',//Interface text box display value
		selectboxheight:200,
		valuefield: ' userid ', url: ' ${path}/assetqueryusername/ Queryrealname.json ', Checkbox:false
		});</span>
Valuefield, the equivalent of getting the ID of the user name, upload it to the background, to operate ()


Action Layer

<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" >/****
 * Query User name * * * 
 @author 
 * *
/@Controller @RequestMapping (value = "/ Assetqueryusername ") Public
class Assetqueryusernameaction extends Baseaction {
	@Autowired
	private Assetqueryusernameservice Assetqueryusernameservice;

	/***
	 * Inquire the name of the asset issuing person
	/@RequestMapping (value = "/queryrealname.json", method = {
			Requestmethod.get , requestmethod.post})
	@ResponseBody public
	Object queryrealname (snuser snuser, httpservletrequest request {
		list data = (list) assetqueryusernameservice.queryrealname (Snuser,
				request);
		return data;
	}
</span>
Service Layer
<span style= "FONT-FAMILY:KAITI_GB2312;FONT-SIZE:18PX;" > @Service public
class Assetqueryusernameservice extends Baseservice<snuser, string> {

	/***
	 * Query the name of the asset issue * * 
	 @param realname
	 * @param userid * 
	 @param request
	 * @return
	/Public List Queryrealname (Snuser snuser,
			httpservletrequest request) {
		String hql = "from Snuser where userlevel= ' 0 '"; c12/>//query User Object
		list<snuser> listuser = this.listbyhql (HQL);
		Returns the list set return
		Listuser
	}
}
</span>

Here to use the SPRINGMVC technology, follow-up article will be specific introduction, a simple small function to achieve, try to try, very simple ~


Related Article

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.