J2EE学习(1)—jsp的基础知识汇总

来源:互联网 发布:千图成像软件 编辑:程序博客网 时间:2024/05/16 10:45

一、EL(expression language)
EL提供了在JSP脚本编制元素范围外使用运行时表达式的功能。脚本编制元素是指页面中能够用于在JSP文件中嵌套java代码的元素。它们通常用于对象操作以及执行那些影响生成内容的计算。
其语法结构如下:

    `${sessionScope.user.name}`
上述表达式的意思是在session范围中找到user对象的name属性,以上EL表达式若换成JSP脚本的话为:
    <%       User user = (User) session.getAttribute("user");       out.print(user.name);      %>
${sessionScope.user.name}

等价于

${sessionScope.user.["name"]}

EL表达式中的隐含对象
1. pageScope 取得Page范围属性名称中的值;
2. requestScope 取得Request范围属性名称中的值;
3. sessionScope 取得Session范围属性名称中的值;
4. applicationScope 取得Application范围属性名称中的值;
5. pageContext 取得JSP中的PageContext。

0 0