JSTL use experience

zhaozj2021-02-16  56

When I used JSTL for the first time, I felt that it was such a means of using it. It is not as convenient to use JSP, but I really feel the powerful and huge advantages of it in the future. I am using it. JSTL's way, I hope to help people who learn it.

JSTL Core Tag Library supports output, variable management, conditional loop statement, text imports, and url manipulation. In the JSP page, you can introduce the following tags to make JSP support JSTL:

<% @ taglib prefix = "c" uri = "http://java.sun.com/jstl/core"%>

is written data,

Is saved data to memory,

Is deleting data,

It is throwing an error message. The detailed usage of various labels will be described below.

1,

will

Test.testinfo

Save the value to

session

of

TEST2

Ammonious

Test

Is an

Javabean

Example,

Testinfo

Yes

Test

The properties of the object.

Save the value of the Cust.Address value value to the Variable CITY

2,

Your user name is:

Display the user name of the user, if the space is displayed, Guest

Specifies to get the value of UserName from the session;

The value of the username is displayed, and the default is taken from the request (page). If there is no user named username in the requestion, it is taken from the session, and the session is not taken from Application (servletContext). If no value is not taken, no value display.

3,

Remove the Collection Variable from the Request.

example:

?

Value = "1234" scope = "request" />

4,

User.Wealthy Is True.

If the user.wealthy value True, User.wealthy is true is displayed.

5,

with

,

User.Generous is true.

User.stingy is true.

User.generous and user.stingy is false.

?

User.Generous is true is displayed only when the condition user.Generous returns is TRUE.

User.stingy is true is displayed only when the condition user.stingy returns is TRUE.

All other situations (ie, user.generous and user.sting are not true) all display user.Generous and user.stingy is False.

6,

?

Equivalent to the Java statement

For (int i = 0; i

{

Out.println (Vectors.get (i));

}

?

Here, Vectors is a Java.util.Vector object, which is stored in String data, and Vector is the String object under the current cycle. In fact, the VECTORS here can be any object that implements the java.util. Collection interface.

Count =

?

?

Output:

COUNT = 0

...

Count = 10 7,

The use of this label is equivalent to the Java.util.StringTokenizer class. Here, the string A: B: C: D is followed by: Separate loop four times, token is a string that is looped to the currently split. 8,?

Contain URL http://www.url.com/edit.js to the current location of the current page and save the URL into the newsfeed variable "/>

Output in the current position of the current page, http: //www.yourname.com is the location of the current page. 9,

Re-direction request to http://127.0.0.1/sample/jstltest1.jsp page, equivalent to Response.setRedirect (http://127.0.0.1/sample/jstltest1.jsp);

10,

Tags are used to transfer parameters to a redirect or contain page

Pass the parameter 888 with the name to the login.jsp page, which is equivalent to login.jsp? Id = 888

The code for receiving data at the receiving end page is:

And there are still a lot of labels that are not listed here, welcome to learn exchange experience. ?

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

New Post(0)