今天写程序时,需要根据active值的不同,分别显示“开始”或“停止”,而且是在jsp中完成,不是在js文件中用javascript。因此用到了Core标签库中的if和choose。
因为用普通的if else无法获得html标签中的值,所以用了<c:if>获得值来进行判断,其用法如下;
- <c:if test=”${user.visitCount==1}”>
- This is your first visit .
- </c:if>
因为<c:if>没有else语句,而我需要用到else的情况,因此可以使用<c:choose>,其用法如下:
- <c:choose>
- <c:when test="${sessionScope.USERTYPE == 'inner'}">
- <c:set value="${context_root}/igmgr/MEB004.dow" var="action" scope="page"/>
- </c:when>
- <c:when test="${sessionScope.USERTYPE == 'merc'}">
- <c:set value="${context_root}/igmgr/MEB021.dow" var="action" scope="page"/>
- </c:when>
- <c:otherwise>
- <c:set value="${context_root}/igmgr/MEB020.dow" var="action" scope="page"/>
- </c:otherwise>
- </c:choose>
core标签库还有其他的标签,例如:<c:out> 、 <c:set> 、 <c:remove> 、 <c:cath>,这些没有用到,所以不太熟悉。
写好的程序如下:
- <c:forEach var="sample" items="${sampleList}">
- <tr>
- <td >${sample.spotNum}</td>
- <td >${sample.dev_code}</td>
- <td>${sample.dust}</td>
- <td>${sample.noise}</td>
- <td>${sample.wind_direct}</td>
- <td>${sample.wind_speed}</td>
- <td>${sample.temp}</td>
- <td>${sample.humid}</td>
- <td>${sample.time}</td>
- <td>${sample.rain_stat}</td>
- <td>${sample.motor_speed}</td>
- <td>${sample.bat_volt}</td>
- <td>${sample.laser_inten}</td>
- <td>${sample.bat_mod}</td>
- <td>${sample.active}</td>
- <c:choose>
- <c:when test="${sample.active==true}"> <td>停止</td> </c:when>
- <c:otherwise> <td>开启</td> </c:otherwise>
- </c:choose>
- </tr>
- </c:forEach>
相关推荐
◎ JSTL的基本概念、安装与配置 ◎ JSTL的通用标记:<c:out>、<c:set>、<c:remove>和<c:catch>标记...◎ 条件处理标记:<c:if>、<c:choose>、<c:when>和<c:otherwise>标记 ◎ 循环标记:<c:forEach>和<c:forTokens>标记
stl的配置方法:<br>1、将jstl.jar和standard.jar拷贝到web-inf/lib下即可(如只使用EL表达式,无需引用这两个包)<br><br>2、在jsp页面头部引入taglib方法如下:<br> <%@ taglib prefix="c" uri=...
用于复杂判断的 <c:choose>?、 <c:when>?、 <c:otherwise>?标签? 用于循环的 <c:forEach>?标签 用于分隔字符的 <c:forTokens>?标签? 用于包含页面的 <c:import> 用于得到 URL?地址的 <c:url>?标签? 用于页面...
<c:if test="${pageNumber>1}"> <a href="Posts?pageNumber=${pageNumber-1}">上一页</a> </c:if> 跳转到第 <select name="pageNumber" onchange="gotoSelectedPage();"> <c:forEach begin="1" end="${...
<c:forEach items="${requestScope.students}" var="student" varStatus="num"> <tr> <td>${num.count}</td> <td>${student.sname}</td> <td><c:out value="${student.spass}" default=...
5.2.3、第三种Scriptlet:<%=%> 5.3、Scriptlet标签 5.4、page指令 5.4.1、设置页面的MIME 5.4.2、设置文件编码 5.4.3、错误页的设置 5.4.4、数据库连接操作 5.5、包含指令 5.5.1、静态包含 5.5.2、动态...
5.2.3、第三种Scriptlet:<%=%> 5.3、Scriptlet标签 5.4、page指令 5.4.1、设置页面的MIME 5.4.2、设置文件编码 5.4.3、错误页的设置 5.4.4、数据库连接操作 5.5、包含指令 5.5.1、静态包含 5.5.2、动态...
5.2.1、第一种Scriptlet:<%%> 5.2.2、第二种Scriptlet:<%!%> 5.2.3、第三种Scriptlet:<%=%> 5.3、Scriptlet标签 5.4、page指令 5.4.1、设置页面的MIME 5.4.2、设置文件编码 5.4.3、错误页的设置 5.4.4、...
5.2.1、第一种Scriptlet:<%%> 5.2.2、第二种Scriptlet:<%!%> 5.2.3、第三种Scriptlet:<%=%> 5.3、Scriptlet标签 5.4、page指令 5.4.1、设置页面的MIME 5.4.2、设置文件编码 5.4.3、错误页的设置 5.4.4、...
5.2.1、第一种Scriptlet:<%%> 5.2.2、第二种Scriptlet:<%!%> 5.2.3、第三种Scriptlet:<%=%> 5.3、Scriptlet标签 5.4、page指令 5.4.1、设置页面的MIME 5.4.2、设置文件编码 5.4.3、错误页的设置 5.4.4、...
5.2.3、第三种Scriptlet:<%=%> 5.3、Scriptlet标签 5.4、page指令 5.4.1、设置页面的MIME 5.4.2、设置文件编码 5.4.3、错误页的设置 5.4.4、数据库连接操作 5.5、包含指令 5.5.1、静态包含 5.5.2、动态...
5.2.3、第三种Scriptlet:<%=%> 5.3、Scriptlet标签 5.4、page指令 5.4.1、设置页面的MIME 5.4.2、设置文件编码 5.4.3、错误页的设置 5.4.4、数据库连接操作 5.5、包含指令 5.5.1、静态包含 5.5.2、动态...
5.2.1、第一种Scriptlet:<%%> 5.2.2、第二种Scriptlet:<%!%> 5.2.3、第三种Scriptlet:<%=%> 5.3、Scriptlet标签 5.4、page指令 5.4.1、设置页面的MIME 5.4.2、设置文件编码 5.4.3、错误页的设置 5.4.4、...
EL表达式 (详解) EL表达式 1、EL简介 1)语法结构 ${expression} 2)[]与.... EL 提供.... 当要存取的属性名称中包含一些特殊...=或ne、<或lt、>或gt、<=或le、>=或ge 3.逻辑运算符有三个:&&或and、||或or、!或not ...
1.关键字:JSTL标签、<c:choose>、<c:forEach>、<c:forTokens>、<c:if>、<c:import>、<c:otherwise>、<c:out>、<c:param>、<c:redirect>、<c:remove>、<c:url>、<c:when>、<c:set>、<c:catch>
JSTL标签总结-<c:if>,<c:choose>,<c:forEach>,<c:forTokens>,<c:catch>,<c:remove >,<c:set>,<c:import>,<c:redirect>,<c:url>,<fmt>
jstl标签可以代替<%= %>在jsp文件中书写java代码,jstl标签包括<c:forEach><c:forEach>、<c:if></c:if>以及<c:choose></c:choose>等的使用,可以使java代码在jsp页面中更加规整。 使用jstl标签需要两个jar包
查询出列表,也就是返回list, 在我们这个例子中也就是 List<User> , 这种方式返回数据,需要在User.xml 里面配置返回的类型 resultMap, 注意不是 resultType, 而这个resultMap 所对应的应该是我们自己配置的 ...
JSTL 以及自定义标签开发相关 JSTL 核心标签库标签共有13个,功能上分为4类: 1.表达式控制标签:out、set、remove、catch ...<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
c:choose Tag Section 9.6. c:set and c:remove Tags Section 9.7. c:import Tag Section 9.8. c:url and c:param Tags Section 9.9. c:redirect Tag Section 9.10. c:catch Tag Chapter 10. The Struts ...