Display TAG uses small records

xiaoxiao2021-03-06  40

DISPLAY TAG for a while, I feel very easy to use, I can find it like this in the forum. There is also a small number of people using this stuff, and then I will write articles. Display Tag Lib is a tag library that handles tables on the JSP page. It is very powerful. You can make pairs, data export, group, column sort, etc. Give me a very convenient to use it. It can greatly reduce the amount of code. Among the official website of Display Tag http://displaytag.sourceforge.net. First of all, it is of course to download its JAR package, here you can download the latest version. Place the JAR package under the lib folder of web-infers. There are also two auxiliary packages: Apache's Commons-Lang and Standard packages, more accessories can be downloaded here.

Add a filter org.displaytag.filter.responseoverridefilter org.displaytag.filter-coponseoverridefilter Quote: <% @ Taglib Uri = "http://displaytag.sf.net/EL" prefix = "display"%> First we define a list <% list test = new arraylist (6); test.add ("Test String 1 "); Test.Add (" Test String 2 "); Test.Add (" Test String 3 "); Test.Add (" Test String 4 "); Test.Add (" Test String 5 "); TEST .add ("Test String 6"); Request.SetaTRibute ("Test", Test);%> When we want to display this list on the JSP page, we only need to write a sentence Display TAG automatically generates a Table if the list is thrown from the control layer, Name can use the EL expression to express This is the easiest Display TAG. We can add a style, etc., or the displayed column, the following table shows some If you want to add a link, it is very simple. The following code adds a connection to Name, with ID parameters, Email is also automatically connected to Mailto: xxx <

Display: column proty = "name" URL = "detail.jsp" paramid = "id" paramodding = "id" /> The following describes the most common features of DISPLAY, more features, please refer to http://displaytag.homeip.net/displaytag-examples-1.1/. 1. Page If you want to paid your code, just add one pagesize = "Map of each page", such as

2. Sort by column Sort Display Tag can be sorted by column, that is, click the column name, sort the data of the column. You only need to add sort = "true" to the columns you want to sort, as described below, you can sort the first three columns. Add a defaultsort = "column number" in Display: Table, you can sort the specified columns by default. If table has paging, Display Tag is only sorted by the current page by default, if you want Sort by List, you can add a code between DISPLAY: TABLE: 3. Export data Add export = "true" in Display: Table What will happen! Display Tag defaults to three data export methods: CSV, Excel, XML. In addition, the Display Tag can also be exported to the PDF format, download a helper item/ITEXT.JAR, click to the lib directory, then add a code between DISPLAY: TABLE: , very successful.

4. DISPLAY TAG Properties Set the display: setProperty as a way to change the Display Tag property, but it is too much trouble in each JSP. There are a lot of default properties in the Display Tag, which has a dedicated property file, is in its JAR package in its JAR package, the DisplayTag / Properties / TableTag.Properties you want to change its default properties, we can under Web-INF / CLASSES Create a file displaytag.properties that sets the properties that requires modified properties in the format of the property of tabletag.properties. # Messages in TableTag.properties is set to the prompt information displayed on the page. The default is English, we can change it to Chinese. However, here can only use Unicode, that is to say Chinese characters must be converted to Unicode, this can be converted using the JDK's own Native2ASCII.exe.

转载请注明原文地址:https://www.9cbs.com/read-55589.html

New Post(0)