jsp中c标签的c:if和c:choose判断
2017-05-15 13:34
387 查看
1、
相当于java中的:
1.1 用法
—引入c标签包:
—body中写入判断:
—属性说明:
2、
相当于java中的:
2.1 用法
—同样需要引入c标签包:
—body中判断
属性说明:
<c:if><c:if/>
相当于java中的:
if(true){ }
1.1 用法
—引入c标签包:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
—body中写入判断:
<c:set var="salary" scope="session" value="${2000*2}"/> <c:if test="${salary > 2000}"> <p>我的工资为: <c:out value="${salary}"/><p> </c:if>
—属性说明:
test:条件(${}中为条件)。 var:用于存储条件结果的变量。 scope:var属性的作用域(可省略,默认值为page)。
2、
<c:choose> <c:when test="<boolean>"/> ... </c:when> <c:when test="<boolean>"/> ... </c:when> ... ... <c:otherwise> ... </c:otherwise> </c:choose>
相当于java中的:
if(){ ... }else if(){ ... }else{ ... }
2.1 用法
—同样需要引入c标签包:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
—body中判断
<c:set var="salary" scope="session" value="${2000*2}"/> <p>你的工资为 : <c:out value="${salary}"/></p> <c:choose> <c:when test="${salary <= 0}"> 太惨了。 </c:when> <c:when test="${salary > 1000}"> 不错的薪水,还能生活。 </c:when> <c:otherwise> 什么都没有。 </c:otherwise> </c:choose>
属性说明:
<c:choose>标签没有属性 <c:when>标签只有一个属性: test:意义同<c:if>标签属性 <c:otherwise>标签没有属性
相关文章推荐
- 【JSP 标签】选择判断c:choose
- jsp的<c:if>标签test里面的多个空格导致判断错误
- 如何在JSP页面中使用JSTL标签实现if-else判断
- jsp中jstl标签的类似 if - else 语句 的语法c:choose
- 如何在JSP页面中使用JSTL标签实现if和if-else判断,判断条件使用<%=value%>
- 如何在JSP页面中使用JSTL标签实现if和if-else判断
- c:if,c:choose解决jsp判断问题
- 关于jsp html标签的判断问题 if else 功能
- JSP的<c:choose> <c:forEach> <c:if> <c:when> <c:set>标签
- jsp c:choose c:if标签
- jsp使用<c:choose>标签
- EL表达式----JSP11个隐式对象----EL函数----JSTL核心标签if,foreach
- jsp 标签iterater;if
- jsp自定义标签之ifelse与遍历自定义标签实例
- JSP标签案例----开发If-else和单独的if标签
- JSTL标签用法:<c:choose><c:forEach><c:if><...
- strust if标签判断
- jsp 判断标签的使用
- JSTL(JSP标准标签库)常用标签用法 (流程控制:if,choose,when,otherwise; 迭代:forEach)
- JSTL标签 if else 判断