jsp 标签

<%@taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>


我在项目中常用到的标签代码 分享下

标签
<!---------------下拉框被选绑定----------------------------->
[/code]
<c:forEach var="va" begin="1" end="${totalPage}" step="1">
<c:choose>
<c:when test="${curr==va}">
<option value="${va }" selected="selected">${va }</option>
</c:when>
<c:otherwise>
<option value="${va }">${va }</option>
</c:otherwise>
</c:choose>
</c:forEach>

-------------------------------------------------------
[code="java"]

<c:forEach var="news" items="${five}" >
<c:choose>
<c:when test="${Resume.configMajorKind.majorKindId==news.majorKindId}">
<option value="${news.majorKindId }" selected="selected">${news.majorKindName }</option>
</c:when>
<c:otherwise>
<option value="${news.majorKindId }">${news.majorKindName }</option>
</c:otherwise>
</c:choose>
</c:forEach>


	

<!------------------------男女 下拉框----------------------------->
<select name="stuSex" id="stuSex">
<option value="男" ${students.stuSex=='男'?'selected':'' }>男生</option>
<option value="女" ${students.stuSex=='女'?'selected':'' }>女生</option>
</select>

<!------------------------下拉框值被选定----------------------------->
<select name="cid" id="cid">
<c:forEach var="cl" items="${ClassesList}">
<option value="${cl.cid}" ${students.cid==cl.cid?'selected':'' }>${cl.CName}</option>
</c:forEach>
</select>
<!---------------------------22--------------------------------------->
<c:forEach var="cl" items="${ClassesList}">
<c:if test="${st.cid==cl.cid}">${cl.CName}</c:if>
</c:forEach>


<!------------------------多选操作----------------------------->
 

<script type="text/javascript">
function check(){
if(document.forms[0].elements["op"].checked){
for(var i=0;i<document.forms[0].elements["ids"].length;i++){
document.forms[0].elements["ids"][i].checked=true;
}
}
if(document.forms[0].elements["op"].checked==false){
for(var i=0;i<document.forms[0].elements["ids"].length;i++){
document.forms[0].elements["ids"][i].checked=false;
}
}
}
</script>
<html:form action="editBook.do">
<input type="checkbox" name="op" onClick="check()">
<input type="checkbox" name="ids" value="1">
<input type="checkbox" name="ids" value="2">
</html:form>

<!-----------------表格循环显示数据时,表格行显示不同颜色----------------->
[/code]
<logic:iterate id="users" name="datas" indexId="index">
<c:if test="${index % 2==0}">
<tr bgcolor="#f6f6f6">...</tr>
</c:if>
<c:if test="${index % 2 !=0}">
<tr bgcolor="#ffffff">...</tr>
</c:if>
</logic:iterate>


<table>
<tr><td><input type="checkbox" name="para" /></td><td>编号</td><td>名称</td><td>邮件</td><td>地址</td><td>日期</td><td>状态</td><td>操作</td></tr>
<logic:iterate id="userList" name="userList" type="entity.Users">
<tr><td><input type="checkbox" name="child" /></td><td>${userList.id }</td><td>${userList.name }</td><td>${userList.email }</td><td>${userList.address }</td><td>${userList.regDate }</td><td>正常</td><td>删除</td></tr>
</logic:iterate>
</table>


[code="java"]


<!----------------------页面 分页代码------------------------------------->

<html:form action="list.do">
(${pageNo }/${totalPage })
<c:choose>
<c:when test="${pageNo==0 and totalPage==0}">
首页 上页 下页 尾页
</c:when>
<c:when test="${pageNo==1 and totalPage==1}">
首页 上页 下页 尾页
</c:when>
<c:when test="${pageNo==1}">
首页 上页
<a href="list.do?pageNo=${pageNo+1 }">下页</a>
<a href="list.do?pageNo=${totalPage }">尾页</a>
</c:when>
<c:when test="${pageNo==totalPage}">
<a href="list.do?pageNo=1">首页</a>
<a href="list.do?pageNo=${pageNo-1 }">上页</a>
下页 尾页
</c:when>
<c:otherwise>
<a href="list.do?pageNo=1">首页</a>
<a href="list.do?pageNo=${pageNo-1 }">上页</a>
<a href="list.do?pageNo=${pageNo+1 }">下页</a>
<a href="list.do?pageNo=${totalPage}">尾页</a>
</c:otherwise>
</c:choose>
转到
<select class="tdfont" name="select2" id="select2">
<c:forEach var="va" begin="1" end="${totalPage}" step="1">
<c:choose>
<c:when test="${pageNo==va}">
<option value="${va }" selected="selected">${va }</option>
</c:when>
<c:otherwise>
<option value="${va }">${va }</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>

</html:form>
<!----------------------控制 页面 查询 分页代码------------------------->
<form action="users.do?op=doLists" method="post">
<!-- 0 -->
<c:if test="${pageNo==0 and totalPage==0 }">
     
</c:if>
<!-- 1 -->
<c:if test="${pageNo==1 and totalPage==1 }">
<TABLE width="100%" border="1" cellPadding="4" cellSpacing="0"
borderColorLight="#cccccc" borderColorDark="#ffffff" class="tdfont">
<tbody>
<tr class="tdfont" bgcolor="#f6f6f6" align="left">
<td class="tdfont" align="left">
当前:${pageNo }/${totalPage }页 共 ${total}条 ${totalPage}页     
</td>
</tr>
</tbody>
</TABLE>
</c:if>
<!-- 总记录数大于10 -->
<c:if test="${total>=10}">
<TABLE width="100%" border="1" cellPadding="4" cellSpacing="0"
borderColorLight="#cccccc" borderColorDark="#ffffff" class="tdfont">
<tbody>
<tr class="tdfont" bgcolor="#f6f6f6" align="left">
<td class="tdfont" align="left">
当前:${pageNo }/${totalPage }页 共 ${total}条 ${totalPage }页
<td align="right">
<c:choose>
<c:when test="${pageNo==1}">
首页 上页
<c:if test="${pageNo<totalPage}">
<a href="users.do?op=doLists&pageNo=${pageNo+1 }">下页</a>
</c:if>
<c:if test="${pageNo==totalPage}">
<a href="users.do?op=doLists&pageNo=${totalPage}">下页</a>
</c:if>
<a href="users.do?op=doLists&pageNo=${totalPage }">尾页</a>
</c:when>
<c:when test="${pageNo==totalPage}">
<a href="users.do?op=doLists&pageNo=1">首页</a>
<c:if test="${pageNo>0}">
<a href="users.do?op=doLists&pageNo=${pageNo-1 }">上页</a>
</c:if>
<c:if test="${pageNo-1<0}">
<a href="users.do?op=doLists&pageNo=${1}">上页</a>
</c:if>
下页 尾页</c:when>
<c:otherwise>
<a href="users.do?op=doLists&pageNo=1">首页</a>
<c:if test="${pageNo>0}">
<a href="users.do?op=doLists&pageNo=${pageNo-1 }">上页</a>
</c:if>
<c:if test="${pageNo-1<0}">
<a href="users.do?op=doLists&pageNo=${1}">上页</a>
</c:if>
<c:if test="${pageNo<totalPage}">
<a href="users.do?op=doLists&pageNo=${pageNo+1 }">下页</a>
</c:if>
<c:if test="${pageNo==totalPage}">
<a href="users.do?op=doLists&pageNo=${totalPage}">下页</a>
</c:if>
<a href="users.do?op=doLists&pageNo=${totalPage}">尾页</a>
</c:otherwise>
</c:choose>
转到
<select class="tdfont" οnchange="jumpPage(this.value)"
name="select2" id="select2">
<c:forEach var="va" begin="1" end="${totalPage}" step="1">
<c:choose>
<c:when test="${pageNo==va}">
<option value="${va }" selected="selected">
${va }</option>
</c:when>
<c:otherwise>
<option value="${va }">
${va }
</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
页</td>
</tr>
</tbody>
</table>
<!-- 结束 -->
</c:if>
</form>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值