seo最好的网站,外贸网站做的作用是什么,买公司的网站建设,深圳网站 建设信科网络EL的概念JSP表达式语言#xff08;EL#xff09;使得访问存储在JavaBean中的数据变得非常简单。EL的作用用于替换作用域对象.getAttribute(name);3. EL的应用#xff08;获取基本类型、字符串#xff09;既可以用来创建算术表达式也可以用来创建逻辑表达式。在…EL的概念JSP表达式语言EL使得访问存储在JavaBean中的数据变得非常简单。EL的作用用于替换作用域对象.getAttribute(name);3. EL的应用获取基本类型、字符串既可以用来创建算术表达式也可以用来创建逻辑表达式。在JSP EL表达式内可以使用整型数浮点数字符串常量true、false还有null。${scope.name}获取具体某个作用域中的数据${name}获取作用域中的数据主机查找{pageContext、request、session、application}4. EL的案例4.1创建不相同的键名% page contentTypetext/html;charsetUTF-8 languagejava %
html
headtitleTitle/title
/head
body%request.setAttribute(key,value1);session.setAttribute(key2,value2);application.setAttribute(key3,value3);%h2通过作用域获取对象/h2h2%request.getAttribute(key)%/h2h2%session.getAttribute(key2)%/h2h2%application.getAttribute(key3)%/h2
/hrh2通过El表达式获取数据/h2h2${requestScope.key}/h2h2${sessionScope.key2}/h2h2${applicationScope.key3}/h2/h2h2通过El表达式2获取数据/h2!--通过EL表达式获取数据,${name}获取作用域中的数据主机查找{pageContext、request,session.application}--h2${key}/h2h2${key2}/h2h2${key3}/h2
/body
/html
运行结果我的路径是创建一个el文件夹jsp文件名为Eldemo014.2创建相同的键名得到的结果
% page contentTypetext/html;charsetUTF-8 languagejava %
html
headtitleTitle/title
/head
body%request.setAttribute(key111,value1);session.setAttribute(key111,value2);application.setAttribute(key111,value3);%h2通过作用域对象获取/h2h2%request.getAttribute(key111)%/h2h2%session.getAttribute(key111)%/h2h2%application.getAttribute(key111)%/h2
/hr
//因为有不同的对象所以还是会获取h2通过el表达式获取数据/h2h2${requestScope.key111}/h2h2${sessionScope.key111}/h2h2${applicationScope.key111}/h2
/hr
//因为三个都是key111所以只能获取第一个值h2通过el表达式2获取数据/h2h2${key111}/h2h2${key111}/h2h2${key111}/h2
/body
/html
运行结果5.EL和JSP脚本的区别是用存取不存的数据判断%request.getAttribute() %没有找到返回null${requestScope.name}没找到返回% page contentTypetext/html;charsetUTF-8 languagejava %
html
headtitleTitle/title
/head
body
%request.setAttribute(key111,value1);session.setAttribute(key222,value2);application.setAttribute(key333,value3);
%
h2通过作用域对象获取/h2
%--获取的键不存在返回为null--%
h2%request.getAttribute(key666)%/h2
h2%session.getAttribute(key666)%/h2
h2%application.getAttribute(key666)%/h2
/hr
h2通过el对象获取/h2
%--获取的键不存在返回为null--%
h2${requestScope.key666}/h2
h2${sessionScope.key666}/h2
h2${applicationScope.key666}/h2
/body
/html
运行结果