Iteration
This tag supports two different styles of iterations: iterations on an integer range (similar to the Java language for the ITerator and ENUMERATION class similar to the Java language).
1. Used in integer range iteration:
(Required) BeGin and End Attributes are integer values or results for integer values. Specify the initial value of the iterative index and the termination value of the iterative index.
(Optional) STEP parameters must be an integer value. It specifies the increment of each iterative index, if the STEP property is omitted, the step size is 1. With the VAR attribute, create a variable with the specified name and define a scope, and assign each iterative current index value to the variable, only can be accessed in the
Value TH> | Square TH> TR>
| |||||||
---|---|---|---|---|---|---|---|---|
| c: foreach> TABLE> 2. Used to set iteration Begin = "expression" end = "expression" step = "express"> Body Content c: foreach> The value of items generated by Items Java.util.collection calls iTerator () Java.util.Mapjava.util.map.Entry instance java.util.Iterator iterator element java.util.enumeration enumeration element Object instance array array element basic type value array After packaging array elements with comma delimited String Sub strings javax.servlet.jsp.jstl.sql.resultsql query acquisition Use Begin, End and STEP properties to qualify which elements in the iteration contains a collection. The iterative index is specified in the iterative set of indexes matching. (Note: For content that contains HTML tags, the ESCAPEXML attribute of the td> tr> c: foreach> TABLE> Whether it is an integer or a collection of attributes Varstatus for creating a variable defining a scope, it is an instance of the javax.servlet.jsp.jstl.core.loptagStatus class. This class describes the current state of iteration. Features Getter Description CurrentGetCurrent () Current this iteration (set) IdexGetIndex () Current this iteration from 0 Iteration index countGetgount () Current this iteration from 1 Iterative count firstisfirst () used to indicate current Whether this round of iteration is the first iteration mark Lastislast () is used to indicate whether the current cyber iteration is the last iteration flag becombegin () begin property endGetend () endGetGetStep () STEP attribute value "$ {entrylist}" var = "blogentry" Varstatus = "status"> td> tr> td> tr> c: foreach> TABLE> Conditional Body Content c: if> "$ {entrylist}" var = "blogentry" Varstatus = "status"> td> tr> c: if> td> tr> td> tr> c: foreach> TABLE> Body Content c: by> ... Body Content c: OtherWise> c: choose> Each condition to be tested is represented by the corresponding This is a secret. Web session. c: by> You are useless an unrecognized web protocol. How Did this happy ?! c: OtherWise> c: choose> Abnormal processing The last stream control mark is VAR, then the varying variables specified (with page scope), which enables custom error processing inside the page itself. Body Content c: catch> URL operation 1. The name of the current servlet context appeared in front 2. Rewote the URL for the session management 3. Request parameter name and value of URL encoding The value property is used to specify the basic URL and then mark it if necessary. If this basic URL starts with a slash, then add the context name of the servlet in front. You can use the context attribute to provide an explicit context name. If this property is omitted, the name of the current servlet context is used. This is especially useful because the servlet context name is determined during deployment rather than during development. (If this basic URL is not starting with a slash, then think it is a relative URL, then you don't have to add the following name.) VAR = "name" scope = "scope"> ... c: URL> URL rewrite is automatically performed by If a value is provided for the VAR attribute (you can also provide a corresponding value for the Scope property, this is optional), then assigns the generated URL to this specified variable that defines the scope. Otherwise, the generated URL will be used using the current JSPWriter output. This ability to directly output its results allows the c: URL> The above JSP code is deployed to a servlet context called Blog, which defines the value of the variable Searchterm of the scope Searchterm is set to "Core Library". If a session cookie is detected, the URL generated by the Listing 14 will be similar to the URL in Listing 15. Note: Add the following name to the front, and the request parameter is attached later. In addition, the slash in the KEYWORD parameter value is encoded in accordance with the needs of the HTTP GET parameter (exact, the space is converted into , while the slash is converted into% 2f sequence) . /BLOG/CONTENT/Search.jsp?keyword=foo BAR&month=02/2003 When there is no session cookie, the result of the generated is as follows. Similarly, the servlet context is added to, and the request parameters encoded by the URL encoded are attached to the back. However, the basic URL is overwritten to include the specified session ID. When the browser sends a URL request overwritten in this way, the JSP container automatically extracts the session ID and associates the request with the corresponding session. This way, J2EE applications that require session management do not need to rely on cookies that are enabled by application users. /BLOG/CONTENT/Search.jsp;jsessionId=233379c7cd2d0ed2e9f3963906db4290 KEYWORD = foo bar & month = 02% 2F2003 Import content JSP has two built-in mechanisms to merge the content from different URLs to a JSP page: Include directive and The incrude directive merges the content that is included during the page compile. In essence, the Charencoding = "expression" var = "name" scope = "scope"> ... c: import> The URL attribute specifies the URL to import the content, this property is the only must-select attribute of Where, c: catch> Sorry, The Remote Content Is Not Currently Available. c: if> The last two (optional) properties of the Request redirection ... c: redirect> You can capture an exception for the c: catch> c: if> From a user's point of view, the main difference is that the redirection will update the URL displayed by the browser and thus affect the bookmark settings. It is not like this to forward, it is transparent to the end user. This way, select |