实训第七天
来源:互联网 发布:javascript获取日期 编辑:程序博客网 时间:2024/04/30 09:29
前日回顾:
jsp实际上就是servlet;include(动态/静态)引入方法;注释、声明、java 脚本段等脚本语句;解决中文参数乱码的三个方法;用servlet+jsp+jquery 实现简单相册;
今日内容:
EL(Expression Language) 表达式:
EL 表达式 $ 与 { 之间不能有空格;
JSP EL 操作的内容:1 . 常量; 2 . 运算; 3 . 变量; 4 . 隐私对象;
1 . 常量
a . 布尔型:${true }; b . 整型:${10 }; c . 浮点型:${10.5 }; d . 字符串型:${"yangcheng" } 原样显示;e . 空类型:${null }什么与不显示;${true }; 如果是传过来的对象为 null,会显示null;
2 . 运算
a . EL 算术运算符:+,-,*,/,或 div、% 或 mod;
b . EL 关系运算符:== 或 eq、!= 或 ne、< 或 lt、> 或 le、>= 或 ge;
c . EL 逻辑运算符:&& 或 and、 || 或 or、 ! 或 not;
d . empty (单目) 运算符:用来判断值是否为 null 或空;为空时返回 true;否则返回 false;
ps: ${param.password1 == param.password2 } 是正确的写法;
<!-- $后面不能有空格 --><hr>${1+3 }<hr>${empty "" } ${empty null } ${empty "null" }<hr><%User user = new User();pageContext.setAttribute("user", user);List<User> userlist = new ArrayList<User>();userlist.add(new User());pageContext.setAttribute("userlist", userlist);%>${empty userlist }
3 . 变量
a . 依次从 page,request,session, application 域中查找:${变量名 };
b . 在制定域中查找
Ⅰ . pageContext 域:${pageScope.变量名 };
Ⅱ . requestContext 域:${requestScope.变量名 };
JSTL(JSP Standard Tag Library)--JSP 标准标签库
主要常用标签库:core ;
导入 core 标签库:<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
判断标签:
<c:if >: test 属性就是条件<c:if test ="${empty requestScope.fourth }"><h2> 没有fourth 的属性值</h2>
<c:choose>:<c:when> == if;
<c:if test="${1==2 }">222222</c:if><c:if test="${1==1 }">wwwwwwwwww2</c:if>
<%int a = (int)(Math.random() * 10);pageContext.setAttribute("a", a);%><c:choose><c:when test="${a==1 }">产生的随机数是1</c:when><c:when test="${a==2 }">产生的随机数是2</c:when><c:when test="${a==3 }">产生的随机数是3</c:when><c:otherwise>${a }</c:otherwise></c:choose>
- 实训第七天
- 实训第七天
- MiniDB实训第七天
- 实训第七天笔记
- 七天
- 一周七天
- 七天长假
- 下一个七天
- 国庆七天
- 星海第七天
- 第七天
- 第十七天
- 第十七天
- 第七天
- 第七天
- 第七天
- 第七天
- 放假七天
- Spring-AOP @AspectJ进阶之绑定代理对象
- Centos6.5 安装 RabbitMQ3.6.1
- springmvc上传文件
- JavaScript——回调函数
- Java虚拟机HotSpot笔记
- 实训第七天
- pandas模块简明教程
- shell命令
- oracle行列转换总结
- pads9.5创建电源符号
- 使用IIS发布ASP.NET网页
- React + Redux 的一些建议(上篇)
- 熵,交叉熵,相对熵(KL散度)
- java sdk 上传文件到阿里云 oos