SPRINGMVC notes: JSP page gets a list of background data records

Source: Internet
Author: User

1. Read the records in the database list

The 2.Controller construction model is as follows:

@RequestMapping ("Display.do")
Public Modelandview display (HttpServletRequest request, Modelmap model) {

listModel.addattribute ("list", myList);

/* Here you can append attribute*/

return new Modelandview ("display.jsp");
}

3.display.jsp using inline Java to display records

Page Introduction Class

<%@ page import= "Java.util.List"%>
<%@ page import= "Java.util.HashMap"%>

Get list

<%
list%>

Displaying Data in table Form

<table style= "width:100%" >
<tr>
<td>value1</td>
<td>value2</td>
<td>value3</td>
</tr>
<%for (int i=0;i<list.size (); i++) {%>
<tr>
<td><%out.print (List.get (i). Get ("Key1")); %></button></td>
<td><%out.print (List.get (i). Get ("Key2")); %></td>
<td><%out.print (List.get (i). Get ("Key3")); %></td>
</tr>
<%}%>

</table>

SPRINGMVC notes: JSP page gets a list of background data records

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.