Displays a list in an html table, formatting each item in the list according to the Column tags nested inside of this tag. Use the list attribute to indicate the Collection of data, in some scope, that the tag should operate on. Supports the export of the list data to alternative formats such as CSV, Excel, and XML. The contents of the list can be sorted, and the list can be broken into individual pages for display. If you use this tag in Struts, or in some other framework where the page is included via a jsp:include, you should use the requestURI attribute to indicate where tag generated links should point.
Can contain: JSP
Example
<display:table name="someList" export="true" id="row" requestURI="MyAction.do">
<display:column sortable="true" title="ID"> <c:out value="${row.id}"/> </display:column>
<display:column property="email" autolink="true"/>
<display:column property="description" title="Comments"/>
</display:table>
Attributes
| Name | Description | Type |
|---|---|---|
| cellpadding | html pass through attribute. Better using "padding" css attribute in style or class | String |
| cellspacing | html pass through attribute | String |
| class | html pass through attribute | String |
| decorator | Fully qualified class name for a TableDecorator. Use a TableDecorator to provide custom operations against the whole list, such as computing totals. Must extend org.displaytag.decorator.TableDecorator. | String |
| defaultorder | The default order for the sorted column. Valid values are "ascending" (default) or "descending" | String |
| defaultsort | The index of the column that will be used by default for sorting (starting from 1) | int |
| excludedParams | Whitespace separated list containg the name of parameters which should NOT be forwarded during paging or sorting. You can use excludedParams="*" to match (exclude) any parameter. | String |
| export | enable/disable export. Valid values are true or false | boolean |
| frame | html pass through attribute. | String |
| htmlId | html "id" pass through attribute | String |
| id | See "uid". The id attribute can't be a runtime expression in jsp 1.0 compliant containers, while uid will allow it. | String |
| length | number of records to be shown | int |
| list | Reference to the object used as source for the table. Can be an expression like requestScope.object.property . You must define either the name attribute or the list attribute. Using "Name" is suggested. | String |
| name | reference to the object used as source for the table. Can be an expression like requestScope.object.property. In the EL version of the taglibrary this must be an EL expression which points to the source object. | String |
| offset | index of the first record to be shown | int |
| pagesize | number of records in a page | int |
| partialList | enable/disable partialLists. Valid values are true or false | boolean |
| requestURI | When the present, links for sorting, exports, and paging are formed by adding any tag generated parameters to the value of requestURI attribute. | String |
| requestURIcontext | Enable/disable prepending of application context to generated links. Default is true, you can set it to false in order to generate cross-context links. | boolean |
| rules | html pass through attribute. | String |
| size | Used only when partialList=true. Reference to the Integer object containing the size of the total dataset. Can be an expression like requestScope.object.property. In the EL version of the taglibrary this must be an EL expression which points to the source object. | String |
| sort | Use 'page' if you want to sort only visible records, or 'list' if you want to sort the full list, or 'external' if the data is sorted outside displaytag. | String |
| style | html pass through attribute | String |
| summary | html pass through attribute | String |
| uid | Unique id used to identify this table. The object representing the current row is also added to the pageContext under this name and the current row number is added using the key uid_rowNum. Two tables in the same page can't have the same uid (paging and sorting will affect both). If no "htmlId" is specified the same value will be used for the html id of the generated table. | String |
| varTotals | Store a java.util.Map of the column totals in a pageContext variable by this name. The keys of the map are "column" and the column number (first column is "column1", etc); values are the corresponding total for the column; columns that are not marked as to total="true" will be omitted from the map. The variable will ONLY be available within the footer tag and after the end of the table, it is not available with the body of the table or columns. | String |
HTML表格展示与导出
本文介绍了一种在HTML中使用表格展示数据的方法,并支持将数据导出为CSV、Excel和XML等格式。该方法允许对数据进行排序,并可分页显示。适用于Struts框架或通过JSP包含页面的场景。
156

被折叠的 条评论
为什么被折叠?



