jstl_core标签库
先导入这个
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
1
<c:out>输出标签 value代表输出
<c:out value="${param.action }"></c:out>
2
<c:if>标签 test代表判断值
<c:if test="${param.action=='dd'}">
<c:out value="${param.text }"></c:out>
</c:if>
<c:set var="salary" scope="session" value="${2000*2}"/>
<c:if test="${salary > 1}">
3
choose ,otherwise
<c:choose>
<c:when test="${param.text >3}">
when<br>
</c:when>
<c:otherwise>
otherwise
</c:otherwise>
</c:choose>
4
var定义变量,begin初始值,end结束条件,step控制步长
<c:forEach var="number" begin='2' end='100' step='2'>
<div>${number }</div>
</c:forEach>
5
list循环,items=${personList} var="person"
<c:forEach items="${personList }" var="person">
辅助代码
List<Person> personList = new ArrayList<Person>();
Person person1 = new Person();
person1.setName("huanggabin");
person1.setAge(2);
Person person2 = new Person();
person2.setName("xiaoming");
person2.setAge(2);
personList.add(person1);
personList.add(person2);
request.setAttribute("personList",personList);//一定要加,保存到request中
6
set标签,var 定义变量,value设置属性值,scope设置范围,target设置对象,(就是var 和target互补吧
然后有了target同时要出现property,使用set可以代替,<jsp:bean><jsp:setProperty> (当然在request添加了这个对象
<c:if test="$param.name != null">
<c:set target="${person }" property="name" value="${param.name }"></c:set>
${person.name}
<c:set target="${person }" property="age" value="${param.age }"></c:set>
${person.age}
</c:if>
7
<c:catch var ="catchException">
<% int x = 5/0;%>
</c:catch> <c:if test = "${catchException != null}">
<p>The exception is : ${catchException} <br />
There is an exception: ${catchException.message}</p>
</c:if>
8
<c:redirect url="http://www.baidu.com">
<c:param name="people" value="huanggabin"></c:param>
</c:redirect>
最新文章
- canvas检测边界和弹动的实例
- 【leetcode】Valid Parentheses
- 安装mysql后ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var mysql 启动不了
- python闭包与装饰器
- 【Qt】2.4 做一个“猜数字”的游戏
- Volley框架的流程图分析
- C#高级特性
- 轻松应对C10k问题
- IIS6、IIS7和IIS8各版本的差别
- HDU 3501 Calculation 2
- springmvc获取jar中的静态资源与jar包中的资源互相引用问题
- Java语言的学习
- Redis客户端断开重连功能要点
- Spark的Streaming + Flume进行数据采集(flume主动推送或者Spark Stream主动拉取)
- python学习(四)
- linux运维、架构之路-linux文件属性
- java中跳出循环的方式
- Unity萌新日记—开发小技巧与冷知识(脚本篇)
- MySQL的max_user_connections拒绝连接的一次踩雷经验
- Oracle查询结果中的日期格式显示到毫秒数,如何去掉多余的数
热门文章
- 无密码登陆的ssh和ssh-agent
- magento: Your web server is configured incorrectly. As a result, configuration files with sensitive information are accessible from the outside 解决方案
- 【fzu-2261】浪里个浪
- 在关于原生js获取getAttribute如果是src的一点注意事项
- droppable放置组件
- [转载]latex插入两栏的图形或表格
- encodeURI()和encodeURIcomponent()的共同点和不同点
- CUDA Samples: Streams' usage
- 随想录(kgdb的基本原理)
- Android 贝塞尔曲线解析