The list of action in the JSP page how to display the summary of the problem __jsp

Source: Internet
Author: User

Method-Set the Get and set methods directly on the action, and then use the iterator iteration output in the JSP page, but be sure to pay attention to the format. This is the format that I've been doing all afternoon.

<s:iterator value= "list" id= "id" > <tr><td><s:property value= "#id. Number"/></td>/ Use tags <td>${id.name}</td></tr>//use El expressions </s:iterator>

Or do not declare ID, direct <s:property value= "number"/>

Method 2: The list is stored in request, and the display method is the same as the JSP page. But personally it is superfluous. Since struts provides the parameters of the interceptor, why don't we take advantage of it, the format is as follows:

<s:iterator value= "#request. List" >//Here must be added #request, indicating that the list is removed from the stack. You can also set an ID, but the following format is #id.number. Also must add #, indicating that the value from the stack <tr><td><s:property value= "number"/></td> <td><s:property value= " Name "/></td></tr> </s:iterator>

Hey, recently is a small problem can torture me a day of time, it seems that is because I usually study when not careful, very impetuous. One thing has not yet mastered, and hurriedly learn another thing, and easy to get into a dead alley. Often learning a new thing will be because of the previous knowledge will not, but also back to the previous legacy of the focus. This is a waste of time. Later I want to make good arrangements for my study plan, reading also want to calm down, not anxious to

This iterator article is not bad: http://hi.baidu.com/songjiafeng/blog/item/5b5a6c4bf3375e2b08f7ef71.html

Note: 1. Just read an article to say: we use struts2 some of the tags, attributes are required to accept the collection, if the collection is stored in request,session, or the value stack (not the root of the stack), you can use the # variable name of the way, If you get a value that is obtained by a specific method in the action, you need to use a way such as value= "userlist", just to remove the front #.

2. The expression used internally within the STRUTS2 label is%{} as the OGNL expression, which can be used in a JSP page with the form ${} as an El expression.

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.