Messagelist. do-> messagelist. jsp
Use messagelist. do? Start = 0 to display the first page
Parameter description:
List: Information list
Start: start position
Page: Number of information displayed on each page
Previous: Start position of the previous page
Next: Start position of the next page
The perform in MessageListAction is written as follows:
Bytes ------------------------------------------------------------------------------------
Int start = Integer. parseInt (request. getParameter ("start "));
System. out. println ("Start:" + start );
Int page = 4;
// Create a message list
Message [] list = new Message [16];
For (int I = 0; I <list. length; I ++ ){
List [I] = new Message (I, "message" + I );
}
Request. setAttribute ("list", list );
Request. setAttribute ("start", new Integer (start ));
Request. setAttribute ("page", new Integer (page ));
// If there is a previous page, set the previous variable
Int previous = start-page;
If (previous> = 0 ){
Request. setAttribute ("previous", new Integer (previous ));
System. out. println ("previous:" + previous );
}
// If there is a next page, set the next variable
Int next = start + page;
If (next <list. length ){
Request. setAttribute ("next", new Integer (next ));
System. out. println ("next:" + next );
}
Return (mapping. findForward ("success "));
Bytes ------------------------------------------------------------------------------------
The content in messagelist. jsp is as follows:
Bytes ------------------------------------------------------------------------------------
<Logic: iterate id = "message" name = "list" offset = "start" length = "page">
<Br>
ParamId = "id" paramName = "message" paramProperty = "id"
Page = "/messagedetail. do">
<Bean: write name = "message" property = "name"/>
</Html: link>
</Logic: iterate>
<Logic: present name = "previous">
<Br>
ParamId = "start" paramName = "previous"
Page = "/messagelist. do">
Previous Page
</Html: link>
</Logic: present>
<Logic: present name = "next">
<Br>
ParamId = "start" paramName = "next"
Page = "/messagelist. do">
Next Page
</Html: link>
</Logic: present>
Bytes ------------------------------------------------------------------------------------
This example illustrates the usage of logic: iterate in pages.
Every time messagelist. do processes all messages, the performance can be optimized.
For example, store the message array in the session.