JSP to obtain data from the database as a drop-down menu option to implement

Source: Internet
Author: User
Tags implement
js| Menu | data | database | dropdown

With JSP for Web development, many occasions to use the Drop-down menu. A few months ago, I did it, but I forgot it today. After looking for a long time to make again, today deliberately to write it down.

<select name= "Sortname" >
<%
while (Iterator.hasnext ()) {String name = ((Sort) Iterator.next ()). GetName (); %>
<option name= "Sortname" value= "<%=name%>" ><%=name%></option>
<%}%>
</select>

Note: Name is a database-related field!

Above is the main code, in front of it plus get iterator code, then the action can get sortname to do related operations.

Actually do it and find it very simple.

The next step is to learn to use the struts tag to handle it. The



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.