当前位置:网站首页>El expression
El expression
2022-04-21 11:23:00 【Carbon water carbon water】
Tips
${ expression }
-
Expression Language, Expression language
-
effect : Instead of jsp The expression script in the page is in jsp Data output in the page , Relatively speaking, it is more concise
-
EL The expression is outputting null When it's worth it , Output Empty string
jsp Expression script output null When it's worth it , Output null character string .
-
jsp All four domain objects in the store have the same name key variable , According to the four fields From small to large Search in the order of , Find it and output it , Except in special situations , Otherwise, only
request -
EL When an expression gets a value , Not looking for property name , Instead, find the attribute Corresponding get Method , Even if not This attribute , Yes get The method can be
obtain expression result / remarks Object properties ${p.name} Array ${p.phones} Address of array An attribute value of the array ${p.phones[2]} List aggregate ${p.cities} [ Elements 1, Elements 2, Elements 3, Elements 4] List Individual element values in the collection ${p.cities[2]} Map aggregate ${p.map} {key1=value1,key2=value2,key3=value3} Map One of the groups key Value ${p.map.key}
operation
Relationship between operation
| Relational operator | say bright | Fan example | result |
|---|---|---|---|
| == or eq | be equal to | ${ 5 == 5 } or ${ 5 eq 5 } | true |
| != or ne | It's not equal to | ${ 5 !=5 } or ${ 5 ne 5 } | false |
| < or lt | Less than | ${ 3 < 5 } or ${ 3 lt 5 } | true |
| > or gt | Greater than | ${ 2 > 10 } or ${ 2 gt 10 } | false |
| <= or le | Less than | be equal to ${ 5 <= 12 } or ${ 5 le 12 } | true |
| >= or ge | Greater than | be equal to ${ 3 >= 5 } or ${ 3 ge 5 } | false |
Logical operations
| Logical operators | say bright | Fan example | result |
|---|---|---|---|
| && or and | And operation | ${ 12 == 12 && 12 < 11 } or ${ 12 == 12 and 12 < 11 } | false |
| || or or | Or operations | ${ 12 == 12 || 12 < 11 } or ${ 12 == 12 or 12 < 11 } | true |
| ! or not | Reverse operation | ${ !true } or ${not true } | false |
Arithmetic operation
| Arithmetic operator | say bright | Fan example | result |
|---|---|---|---|
| + | Add | ${ 12 + 18 } | 30 |
| - | Subtraction | ${ 18 - 8 } | 10 |
| * | Multiplication | ${ 12 * 12 } | 144 |
| / | or div division | ${ 144 / 12 } or ${ 144 div 12 } | 12 |
| % | or mod modulus | ${ 144 % 10 } or ${ 144 mod 10 } | 4 |
empty operation
You can judge whether a data is empty , If it is empty , The output true, Not empty output false
The following situations are empty :
- The value is null When it's worth it , It's empty
- When the value is an empty string , It's empty
- The value is Object Type array , When the length is zero
- list aggregate , The number of elements is zero
- map aggregate , The number of elements is zero
The ternary operation
Same as java The ternary operation
. operation and [] Operator
-
. Point operation : Can output Bean The value of an attribute in an object
-
[] In brackets , You can output the value of an element in an ordered collection , Single and double quotation marks are OK
also [] In brackets , You can also output map Collection key Containing special characters key Value .
request.setAttribute("abc.def", "zhangsan");
// use . Can't value
//${requestScope.abc.def}
${
requestScope["abc.def"]}
<body>
<%
Map<String,Object> map = new HashMap<String, Object>();
map.put("a.a.a", "aaaValue");
map.put("b+b+b", "bbbValue");
map.put("c-c-c", "cccValue");
request.setAttribute("map", map);
%>
${ map['a.a.a'] } <br>
${ map["b+b+b"] } <br>
${ map['c-c-c'] } <br>
</body>
Implied objects
11 A hidden object
| Variable | type | effect |
|---|---|---|
| pageContext | PageContextImpl | It can get jsp Nine built-in objects in |
| pageScope | Map<String,Object> | It can get pageContext Data in domain |
| requestScope | Map<String,Object> | It can get Request Data in domain |
| sessionScope | Map<String,Object> | It can get Session Data in domain |
| applicationScope | Map<String,Object> | It can get ServletContext Data in domain |
| param | Map<String,String> | It can get the value of the request parameter |
| paramValues | Map<String,String[]> | It can also get the value of the request parameter , Use when getting multiple values . |
| header | Map<String,String> | It can get the information of the request header |
| headerValues | Map<String,String[]> | It can get the information of the request header , It can get multiple values |
| cookie | Map<String,Cookie> | It can get the current request Cookie Information |
| initParam | Map<String,String> | It can be obtained in web.xml The context parameters configured in the |
pageContext
obtain jsp Nine built-in objects in
Can directly pageContext. object . Method , It's fine too pageContext.setAttribute Name the object and use it directly
<% pageContext.setAttribute("req", request); %>
<%=request.getScheme() %>
1. agreement : ${ req.scheme }
2. The server ip:${ pageContext.request.serverName }
3. Server port :${ pageContext.request.serverPort }
4. Get the project path :${ pageContext.request.contextPath }
5. Get request method :${ pageContext.request.method }
6. Get the client ip Address :${ pageContext.request.remoteHost }
7. Get the id Number :${ pageContext.session.id }
Get properties in four specific domains
| EL expression | Domain |
|---|---|
| pageScope | pageContext Domain |
| requestScope | Request Domain |
| sessionScope | Session Domain |
| applicationScope | ServletContext Domain |
<%
pageContext.setAttribute("key", "pageContext");
request.setAttribute("key", "request");
session.setAttribute("key", "session");
application.setAttribute("key", "application");
%>
${pageScope.key}
${requestScope.key}
${sessionScope.key}
${applicationScope.key}
param And paramValues
Output request parameters username Value :${ param.username }
Output request parameters password Value :${ param.password }
Output request parameters username Value :${ paramValues.username[0] }
Output request parameters hobby Value :${ paramValues.hobby[0] }
Output request parameters hobby Value :${ paramValues.hobby[1] }
header And headerValues
Output request header 【User-Agent】 Value :${ header['User-Agent'] } <br>
Output request header 【Connection】 Value :${ header.Connection } <br>
Output request header 【User-Agent】 Value :${ headerValues['User-Agent'][0] } <br>
cookie
obtain Cookie The name of :${ cookie.JSESSIONID.name }
obtain Cookie Value :${ cookie.JSESSIONID.value }
initParam
obtain web.xml Configuration in :
<context-param>
<param-name>username</param-name>
<param-value>root</param-value>
</context-param>
<context-param>
<param-name>url</param-name>
<param-value>jdbc:mysql:///test</param-value>
</context-param>
Output Context-param username Value :${ initParam.username } <br>
Output Context-param url Value :${ initParam.url } <br>
版权声明
本文为[Carbon water carbon water]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211122218051.html
边栏推荐
- Solution to the display of the name of xftp file
- JSON及相关
- L3-028 森森旅游 (30 分) (dijkstra+反向建图+细节)
- 实现将80端口请求转发到其他端口
- NCURSES 安装包,以及pkg-config信息
- 万元礼品奖池 玩转「Lighthouse」有奖征文来袭
- 54000 stars all return to zero. Project Author: I regret it very much
- Matlab GUI --- piczoom animation demonstration
- I need to write two interfaces to receive data, and then store the data in the database to complete data persistence
- Suffix Array
猜你喜欢
![[interview ordinary people vs Expert Series] understanding of B tree and B + tree](/img/17/a81da0a2e6b0c7cb218879f1a79861.jpg)
[interview ordinary people vs Expert Series] understanding of B tree and B + tree

pgpool-II 4.3 中文手册 - 入门教程

pycharm中归一化记录

塔米狗资讯|国资委发言:支持上市公司采用企业并购融资手段拓展主业
![[nonlinear control theory] 1_ Lyapunov direct method](/img/ad/68bceb288d40ae98b60dbb83e0b91d.png)
[nonlinear control theory] 1_ Lyapunov direct method

互联网快讯:拓荆科技成功登陆科创板;极米H3S、极米Z6X Pro持续热销;盒马在上海启动“流动超市”

Teach you to easily solve CSRF Cross Site Request Forgery Attack

Leetcode1615. 最大网络秩(medium,图论基础)

循环队列的长度「In DataStructure」

MATLAB---坐标轴多图片显示
随机推荐
pycharm中归一化记录
Intelligent party building platform system development, and promote the construction of "Internet plus party building"
JSTL -- JSP 标准标签库
Chalk technology implements the Omo integration mode, and the dual core drives the rapid growth of revenue
Redis数据库
How does IOT platform realize business configuration center
I18N 国际化
org. apache. flink. client. deployment. ClusterDeploymentException: Could not deploy Yarn job cluster.
Question brushing & Competition & Review
1. Precision marketing practice Alibaba cloud odpscmd precision marketing data processing
1.精准营销实践阿里云odpscmd精准营销数据处理
js---call,apply,bind
【优质原创】分享几个Sklearn模块中不为人知又超级好用的API函数
连接服务器报错No supported authentication methods available
Code analysis of suffix array template
智慧党建平台系统开发,推进“互联网+党建”建设
文件传输(上传下载)
Solution to the display of the name of xftp file
便利店卷疯了:便利蜂、罗森、易捷“激战”
使用 RSA 进行加解密