request.getSession().setAttribute("msg", "修改成功");=============》》获取 <span>${msg }</span>
console.info(msg);
<c:choose>
<c:when test="${empty list}">
<tr>
<td colspan="6">没有找到数据</td>
</tr>
</c:when>
<c:otherwise>
<c:forEach var="s" items="${list}" varStatus="va">
<tr class="${va.index%2==0?"":'bg' }">
<td><a href="id?a=${s.sid }">${s.sid }</a></td>
<td>${s.sname }</td>
<td>${s.sgender }</td>
<td>${s.sage }</td>
<td>${s.saddress }</td>
<td>${s.semail }</td>
</tr>
</c:forEach>
</c:otherwise>
</c:choose>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> if foreach 常用
<tbody>
<c:if test="${empty list}">
<tr>
<td colspan="4">没有符合条件的记录!</td>
</tr>
</c:if>
<c:if test="${not empty list}">
<c:forEach var="s" items="${list}">
<tr>
<td>${s.id}</td>
<td>${s.name }</td>
<td>${s.age }</td>
<td>${s.cTime }</td>
</tr>
</c:forEach>
</c:if>
</tbody>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<td><fmt:formatDate value="${d.cTime}" pattern="yyyy年MM月dd日 hh:mm:ss"/></td>格式化年月日
<td><fmt:formatNumber value="${1183322.76}" pattern="###,###.0000"/></td>金钱
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<td>${fn:substring(d.name,0,2)}</td>字符串截取
index页面
<%
Employee em=new Employee("张三",new Computer("联想"));
request.setAttribute("hong",em);
request.getRequestDispatcher("doIndex.jsp").forward(request,response);
%>
doIndex页面
${hong.name}使用的电脑品牌为${hong.computer.brand }
input页面
<form action="doInput.jsp" method="post">
昵称:<input type="text" name="nikename"/><br/>
<input type="checkbox" name="ah" value="篮球"/>篮球
<input type="checkbox" name="ah" value="足球"/>足球
<input type="checkbox" name="ah" value="羽毛球"/>羽毛球<br/>
<input type="submit" value="提交"/>
</form>
doInput页面
${param.nikename }
${paramValues.ah[0] }
${paramValues.ah[1] }
---------------------------------------------------jstl
<body>
<c:set var="username" value="${100+1}" scope="session"></c:set>
删除前:
<c:out value="${sessionScope.username}" default="没有"></c:out>
<c:remove var="username" scope="session"/>
删除后:
<c:out value="${sessionScope.username}"></c:out>
<hr/>
<%
request.setAttribute("hong","<font style='color:red'>张三</font>标签如何使用?");
%>
某人提出问题:
<c:out value="${hong}" escapeXml="true"></c:out>
</body>
-------------------------------------------------------------el
<body>
<%
pageContext.setAttribute("key1", "value1");
request.setAttribute("key2", "value2");
session.setAttribute("key3", "value3");
application.setAttribute("key4", "value4");
%>
${pageScope.key1};
${requestScope.key2};
${sessionScope.key3};
${applicationScope.key4};
</body>
jstl与el表达式
最新推荐文章于 2024-03-24 11:05:36 发布