您的位置:首页 > Web前端 > JavaScript

JSP - EL(Expression Language)

2016-03-31 14:44 337 查看
Expression Language

语法格式:${expression}

EL存取变量数据的方法很简单,例如:

${username},它的意思是取出某一范围中名称为username的变量。
因为我们并没有指定哪一个范围的username,所以它会依序从Page、Request、Session、Application范围查找。

即按照以下顺序查找:

[1]${pageScope.username}

[2]${requestScope.username}

[3]${sessionScope.username}

[4]${applicationScope.username}

假如途中找到username,就直接回传,不再继续找下去,但是假如全部的范围都没有找到时,就回传null。

page

pageScope

request

requestScope

session

sessionScope

application

applicationScope

< %=request.getParameter("username")% > 等价于 ${ param.username }

因为是request.getParameter(String name),EL中有对应的隐式对象:param,所以可以param.user

<%=request.getAttribute("userlist") %> 等价于$ { requestScope.userlist }

其他范围下,写法类似
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  EL表达式 JSP