JSP foreach Fetch map

Source: Internet
Author: User

The value of the map is taken out of the JSP and a check box is generated based on the key value;

The package to use

<%@ Page Import="Com.hebrf.dbmanage.DBManage"%><%@ Page Import="com.hebrf.dbmanage.DBFactory"%><%@page Import="java.util.List"%><%@page Import="Java.util.Map"%><%@ taglib Prefix="C"URI="Http://java.sun.com/jsp/jstl/core" %> 

Find a map by database

Dbmanage db = Dbfactory.getdbmanage ();    List lis = Db.getlistbymap ("Select DM as DM,MC as MC from  zdcdzllx");    Request.setattribute ("Lis", Lis);

Get the collection ([{mc= written material, dm=01}, {mc= picture material, dm=02}, {mc= print material, dm=03}, {mc= av material, dm=04}, {mc= check-in table, dm=05}, {mc= other materials, dm=06}]

Loop build check box

        <TDcolspan= "3">    <C:foreachItems= "${lis}"var= "L">                                    <inputtype= "checkbox"name= "Dazllx"value= "${l.dm}"ID= "dazllx${l.dm}"  />                                         <label for= "dazllx${l.dm}">${L.MC}</label>                                </C:foreach>                                </TD>

The resulting effect

written MaterialsPicture MaterialPrinting MaterialsAV materialRegistration FormOther materials

JSP foreach Fetch map

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.