jsp中jstl标签的类似 if - else 语句 的语法
2013-05-27 16:10
387 查看
[b]在jsp中引入jstl的标签库和函数库[/b]
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
[b]1. jsp中传递参数,经过action,存储到request中[/b]
<area shape="poly" coords="680,111,765,82,811,196,724,223"
href="${pageContext.request.contextPath}/news/queryNews.do?artType=9&new=3" alt="摄影" title="摄影" />
[b]2. java代码中有[/b]
String newFlag=request.getParameter("newFlag");
if(newFlag!=null && !newFlag.equals("")){
request.setAttribute("newFlag",newFlag);
}
[b]3. jsp中的类似 if - else 语句 的语法[/b]
<c:choose>
<c:when test="${requestScope.newFlag== '1' || requestScope.newFlag== '2' ||requestScope.newFlag== '3'}">
作品名称: ${star.class_}<br />
作品编号: ${star.raceNum}<br />
</c:when>
<c:otherwise>
班级: ${star.class_}<br />
参赛编号: ${star.raceNum}<br />
</c:otherwise>
</c:choose>
[b]1. 如果在jsp中传递参数,没有经过action ,直接跳转到jsp页面[/b]
<a href="${pageContext.request.contextPath}/reg.jsp?newFlag=${requestScope.newFlag}">
<img src="${pageContext.request.contextPath}/images/reg.png" width="76" height="53" alt="我要注册" title="我要注册" />
</a>
[b]2. 在jsp中取得jsp传过来的参数,此时要使用${param.newFlag}[/b]
<c:choose>
<c:when test="${param.newFlag== '1' || param.newFlag== '2' ||param.newFlag== '3'}">
<th>作品名称<font color="Red">*</font>:</th>
</c:when>
<c:otherwise>
<th>班级<font color="Red">*</font>:</th>
</c:otherwise>
</c:choose>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
[b]1. jsp中传递参数,经过action,存储到request中[/b]
<area shape="poly" coords="680,111,765,82,811,196,724,223"
href="${pageContext.request.contextPath}/news/queryNews.do?artType=9&new=3" alt="摄影" title="摄影" />
[b]2. java代码中有[/b]
String newFlag=request.getParameter("newFlag");
if(newFlag!=null && !newFlag.equals("")){
request.setAttribute("newFlag",newFlag);
}
[b]3. jsp中的类似 if - else 语句 的语法[/b]
<c:choose>
<c:when test="${requestScope.newFlag== '1' || requestScope.newFlag== '2' ||requestScope.newFlag== '3'}">
作品名称: ${star.class_}<br />
作品编号: ${star.raceNum}<br />
</c:when>
<c:otherwise>
班级: ${star.class_}<br />
参赛编号: ${star.raceNum}<br />
</c:otherwise>
</c:choose>
[b]1. 如果在jsp中传递参数,没有经过action ,直接跳转到jsp页面[/b]
<a href="${pageContext.request.contextPath}/reg.jsp?newFlag=${requestScope.newFlag}">
<img src="${pageContext.request.contextPath}/images/reg.png" width="76" height="53" alt="我要注册" title="我要注册" />
</a>
[b]2. 在jsp中取得jsp传过来的参数,此时要使用${param.newFlag}[/b]
<c:choose>
<c:when test="${param.newFlag== '1' || param.newFlag== '2' ||param.newFlag== '3'}">
<th>作品名称<font color="Red">*</font>:</th>
</c:when>
<c:otherwise>
<th>班级<font color="Red">*</font>:</th>
</c:otherwise>
</c:choose>
相关文章推荐
- jsp中jstl标签的类似 if - else 语句 的语法
- jsp中jstl标签的类似 if - else 语句 的语法
- jsp中jstl标签的类似 if - else 语句 的语法c:choose
- jsp中jstl标签的类似 if - else 语句 的语法
- jsp中使用jstl的实现类似if ... else 语句
- jsp中的类似 if - else 语句 的语法
- java web javaEE ,jsp EL表达式和JSTL标签if-else if-else四种用法
- jsp中使用jstl实现类似java的if-else功能的写法
- 如何在JSP页面中使用JSTL标签实现if-else判断
- 如何实现JSTL if else if else 的jsp标签
- 如何在JSP页面中使用JSTL标签实现if和if-else判断,判断条件使用<%=value%>
- 如何在JSP页面中使用JSTL标签实现if和if-else判断
- C language 使用if…else if…else语句实现多分支选择结构*(语法结构同C#)
- Python语法基础(四):if-else语句
- EL表达式类似的if和else语句
- JSTL标签中c:choose,c:when,c:otherwise 可以实现if...else if..else的用法
- jsp自定义标签之ifelse与遍历自定义标签示例
- java学习之路 之 基本语法-程序流程控制-(if-else)语句练习题
- JSP基础语法之十六:JSTL配置和核心标签(C)的使用
- jsp自定义标签之ifelse与遍历自定义标签实例