JSTL using the configuration

sponsored links

JSTL use a configuration summary

1.web.xml version 2.3 version of the configuration


Reference document: http://blog.csdn.net/tiancaoyan/archive/2009/06/10/4256637.aspx

Use of the environment: WebLogic92 + JDK1.5, web.xml version 2.3, that file is as follows:

<! DOCTYPE web-app PUBLIC "- / / Sun Microsystems, Inc. / / DTD Web Application 2.3 / / EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

Use these steps:

l copy jstl.jar, standard.jar files to Web-INF/lib directory

l In reference to JSP page with: <% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%>

l If web.xml version 2.3, but also in plus: <% @ page isELIgnored = "false"%>

2 web.xml version 2.4 configuration


<Web-app version = "2.4"

xmlns = "http://java.sun.com/xml/ns/j2ee"

xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"

xsi: schemaLocation = "http://java.sun.com/xml/ns/j2ee

http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">

l copy jstl.jar, standard.jar files to Web-INF/lib directory

l In reference to JSP page with: <% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%>

3 web.xml version 2.5 configuration


JSTL in J2EE5.0 has been included in standard specifications will be jstl.jar, standard.jar two jar files into jstl1.2.jar.

<Web-app version = "2.5"

xmlns = "http://java.sun.com/xml/ns/javaee"

xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"

xsi: schemaLocation = "http://java.sun.com/xml/ns/javaee

http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd ">

l In reference to JSP page with: <% @ taglib uri = "http://java.sun.com/jsp/jstl/core" prefix = "c"%>

Web.xml above under the various versions of Tomcat6.0.24 can be displayed correctly.

Second, using the example of JSTL


JSTL access range.

Reference document: http://blog.csdn.net/tiancaoyan/archive/2009/06/10/4256637.aspx

An EL expression that contains variables and operators. Any stored in a JSP scope (eg: page, request, session, application) of the bean can be used as an EL variable. In addition, EL supports the following predefined variables:


Variable name


Explain


pageScope


A range that contains all page scope variables collection (a java.util.Map)


requestScope


A range that contains all request scope variables collection (a java.util.Map)


sessionScope


A range that contains all session scope variables collection (a java.util.Map)


applicationScope


A range that contains all application scope variables collection (a java.util.Map)


param


A collection that contains all request parameters (a java.util.Map), corresponding to each parameter by way of assignment of a String value


paramValues


A collection that contains all request parameters (a java.util.Map), corresponding to each parameter by way of assignment of a String array


header


1 contains all the information requested in the first set, (a java.util.Map), by each of the first information corresponding to a String value to assign values


headerValues


A header contains all the requested collection (a java.util.Map), through each header values are stored in a String array to assign values


cookie


A cookie contains a collection of all the requests (a java.util.Map), through each cookie (javax.servlet.http.Cookie) value corresponding to a cookie to assign values


initParam


Application that contains all the initialization parameters set (a java.util.Map), through each parameter corresponds to a String value to assign values


pageContext


A javax.servlet.jsp.PageContext instance of the class, used to provide access to different request data


Operator on the variables you describe the desired action. If you previously used any programming language, in the EL expression used in the operator for you may look familiar. Because they and those in most languages supported by the same operator.

.

Access a bean property or Map entry

[]

Access to an array or list element

()

Pair group expressions, used to change the assignment order

?:

Conditional statements, such as: condition? IfTrue: ifFalse. If the condition is true, the expression value of the former, whereas the latter

+

Mathematical operators, plus operation

-

Mathematical operators, by operation of a value or negated

*

Mathematical operators, by operation

/ Or div

Mathematical operators, in addition to operation

% Or mod

Mathematical operators, module operations (take over)

== Or eq

Logical operators to determine whether the equal sign ends around, if equal return true, otherwise it returns false

! = Or ne

Logical operators to determine whether the symbol is about equal at both ends, if not equal return true, otherwise it returns false

<Or lt

Logical operators to determine whether the symbols on the left than the right, if less than the return true, otherwise it returns false

> Or gt

Logical operators to determine whether the symbols on the left than the right, if more than to return true, otherwise it returns false

<= Or le

Logical operators to determine whether the symbols on the left is less than or equal to the right, if less than or equal to return true, otherwise it returns false

> = Or ge

Logical operators to determine whether the symbol is greater than or equal to the left of the right, if greater than or equal to return true, otherwise it returns false

& & Or and

Logical operator, and operation of Fu. If the same is true about both sides return true, otherwise it returns false

| | Or or

Logical operator, or operating Fu. If there are any left and right side of the true returns true, otherwise it returns false

! Or not

Logical, non-operating Fu. Check operation returns true if false, otherwise it returns true

empty

Used to determine an empty variable value: null, an empty String, empty array, empty Map, there is no entry in the Collection Collection

func (args)

Call the method, func is a method name, args is the argument, can not, or there is one more parameter. Parameters separated by commas

An EL expression can contain: numbers, text (in single quotes or double quotes), Boolean values, null values.

1 for a single object

<% Request.setAttribute ("username", "david")%>

$ (RequestScope.userName)

Two types of traversal Map

<%

Hashtable hashtable1 = new Hashtable ();

hashtable1.put (new Integer (1), "uno");

hashtable1.put (new Integer (2), "dos");

hashtable1.put (new Integer (3), "tres");

request.setAttribute ("numberMap", hashtable1);

/ / JSTL best value of the designated area to visit:

/ / $ (SessionScope. NumberMap2), $ (applicationScope. NumberMap2).

request.getSession (). setAttribute ("numberMap2", hashtable1); request.getSession ()

. GetServletContext (). SetAttribute ("numberMap3", hashtable1);

%>

<c:forEach var="month" items="${numberMap}">

<li>



$ (Month.key), $ (month.value)

</ Li>

</ C: forEach>

The JSTL tag related reference

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

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/xml" prefix = "x"%>

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix = "f"%>

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/sql" prefix = "sql"%>

<% @ Taglib uri = "http://java.sun.com/jsp/jstl/functions" prefix = "fn"%>
  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb
Tags:

Related Posts of JSTL using the configuration

blog comments powered by Disqus
Recent
Recent Entries
Tag Cloud
Random Entries