One, El expression (form: ${})
1. El operator
-
- Arithmetic operators: + 、-、 *,/,%
Example results
${1+1} 2
${1-1} 0
${1*3} 3
${3/2} 1.5
${5%3} 2
-
- Relational operator: greater than, less than, equal to, not equal to, greater than or equal to, less than or equal to
Example results
${2>1} True
${1<0} False
${1==1} True
${3!=2} True
${5>=2} True
${4<=3} False
-
- Logical operators: | |, &&,!
Example results
${true| | True} True
${true| | False} True
${false| | False} False
${true&&true} True
${true&&false} False
${false&&false} False
${!true} False
${!false} True
-
- Conditional operator: ${a? B:C}
Example: ${2>1? "True": "false"} result true
-
- Validation operator: ${empty var}
String username = "Tom";
${empty Username} result true
2. El Built-in objects
-
- Domain Object
- Pagescope
- Requestscope
- Sessionscope
- Applicationscope
- Input Object
- param//Param.username equivalent to Request.getparameter ("username");
- Paramvalues//Paramvalues.hobby equivalent to Request.getparametervalues ("hobby");
- Cookie Object
- ${cookie.username.value}//Gets the value of the username attribute in the cookie
- Initparam Object
- ${initparam.username}//Gets the parameter value in the context object
Such as:
<context-param>
<param-name>username</param-name>
<param-value>tom</param-value>
</context-param>
-
- PageContext Object
- ${pagecontext.request.requesturl}//Get request URL
- ${pagecontext.request.querystring}//Get parameter string
- ${pagecontext.request.contextpath}//Get the current app directory
- ${pagecontext.request.method}//Get Request method
3. El Accessor
-
- Get JavaBean Data
${sessionscope.person.name}
${sessionscope.person.age}
- Get map data
HashMap userinfo= new HashMap (); Userinfo.put ("username", "Tom"); Userinfo.put ("Password", "123456");
${userinfo.username}
${userinfo.password}
${NAMES[0]}//String names = {"Tom", "Lisa", "Jerry"}
${names[0]}
"El&jstl" Study notes