<%@page language="java" contentType="text/html;charset=gb2312"%> <%@page import="java.sql.*" %> <!DOCTYPE html> <html> <head> <title>El算数运算符</title> </head> <body> <table border=1> <tr> <td>算数运算符</td> <td>结果</td> </tr> <tr> <td>加法运算符\${1 + 1}</td> <td>结果${1+1}</td> </tr> <tr> <td>减法运算符\${1 - 1}</td> <td>结果${1-1}</td> </tr> <tr> <td>乘法运算符\${1 * 2}</td> <td>结果${1 * 1}</td> </tr> <tr> <td>除法运算符\${3 / 2}</td> <td>结果${3 / 2}</td> </tr> <tr> <td>求余运算符\${3 % 2}</td> <td>结果${3 % 2}</td> </tr> </table> <table border=1> <tr> <td>关系运算符</td> <td>结果</td> </tr> <tr> <td>等于运算符\${1 == 1}</td> <td>结果${1==1}</td> </tr> <tr> <td>不等于运算符\${1 != 1}</td> <td>结果${1!=1}</td> </tr> <tr> <td>小于运算符\${1 < 2}</td> <td>结果${1 < 2}</td> </tr> <tr> <td>大于运算符\${3 > 2}</td> <td>结果${3 > 2}</td> </tr> <tr> <td>小于等于运算符\${1 <= 2}</td> <td>结果${1 <= 2}</td> </tr> <tr> <td>大于等于运算符\${3 >= 2}</td> <td>结果${3 >= 2}</td> </tr> </table> <table border=1> <tr> <td>逻辑运算符</td> <td>结果</td> </tr> <tr> <td colspan="2">逻辑运算符&&</td> </tr> <tr> <td>\${true && true}</td> <td>结果${true && true}</td> </tr> <tr> <td>\${true && false}</td> <td>结果${true && false}</td> </tr> <tr> <td>\${false && false}</td> <td>结果${false && false}</td> </tr> <tr> <td colspan="2">逻辑运算符||</td> </tr> <tr> <td>\${true || true}</td> <td>结果${true || true}</td> </tr><tr> <td>\${true || false}</td> <td>结果${true || false}</td> </tr><tr> <td>\${false || false}</td> <td>结果${false || false}</td> </tr> <tr> <td colspan="2">逻辑运算符!</td> </tr> <tr> <td>\${!true}</td> <td>结果${!true}</td> </tr><tr> <td>\${!false}</td> <td>结果${!false}</td> </tr> </table> <table border=1> <tr> <td>条件运算符</td> <td>结果</td> </tr> <tr> <td>\${2>1?"Yes":"No"}</td> <td>结果${2>1?"Yes":"No"}</td> </tr> <tr> <td>\${2<1?"Yes":"No"}</td> <td>结果${2<1?"Yes":"No"}</td> </tr> </table> <table border=1> <tr> <td>验证运算符</td> <td>结果</td> </tr> <tr> <td>\${empty param.username}</td> <td>结果${empty param.username}</td> </tr> <tr> <td>\${empty param.password}</td> <td>结果${empty param.password}</td> </tr> </table> <table border=1> <tr> <td>括号运算符及运算符的优先级</td> <td>结果</td> </tr> </table> </body> </html>
EL处理内置对象:
“.”和"[]"符号是用来存取数据的
${applicationScope.user.username} ${applicationScope.user[0].username} ${applicationScope.user["user-name"]}
通过变量来传值就必须使用[]
${applicationScope.user["data"]}
与存储有关的内置对象
<!DOCTYPE html> <html> <head> <title>与存储有关的内置对象</title> </head> <body> <% //application范围设置属性name,值为application_name application.setAttribute("name","application_name"); //session范围设置属性name,值为session_name session.setAttribute("name","session_name"); //request范围设置属性name,值为request_name request.setAttribute("name","request_name"); //page范围设置属性name,值为page_name pageContext.setAttribute("name","page_name"); %> <%--获取page范围内的name属性--%> page范围内的那么属性的值为:${pageScope.name}<br /> <%--获取request范围内的name的属性--%> request范围内的那么属性的值为:${requestScope.name}<br /> <%--获取session范围内的name的属性--%> session范围内的那么属性的值为:${sessionScope.name}<br /> <%--获取application范围内的name属性--%> application范围内的那么属性的值为:${applicationScope.name}<br /> </body> </html>
与输入有关的内置对象