<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'list.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<link rel="stylesheet" href="css/index_work.css" type="text/css"></link>
<script type="text/javascript" src="js/jquery-1.8.2.js"></script>
<script type="text/javascript">
function allcheck(){
$(".ch").attr("checked",true);
}
function notcheck(){
$(".ch").attr("checked",false);
}
function recheck(){
$(".ch").each(function (){
$(this).attr("checked",!$(this).attr("checked"));
});
}
function dels(){
var ids = "";
$(".ch").each(function (){
if($(this).attr("checked")){
ids += ","+$(this).val();
}
});
ids = ids.substring(1);
$.post(
"s_dels",
{"ids":ids},
function (msg){
if(msg!=0){
alert("批删成功");
location="s_list";
}else if(msg==0){
alert("批删失败");
}
},"text"
);
}
function del(id){
if(confirm("删?")){
$.post(
"s_del",
{"student.id":id},
function (msg){
if(msg==1){
alert("执行成功");
location ="s_list";
}else{
alert("执行失败");
}
}
);
}
}
function mohu(cpage){
var mohu = $("#mohu").val();
location = "s_list?mohu="+mohu+"&cpage="+cpage;
}
function gopage(cpage){
mohu(cpage);
}
</script>
</head>
<body>
<table>
<tr>
<th colspan="21">
<input type="text" id="mohu" value="${mohu}"><input type="button" value="查找" onclick="mohu()">
</th>
</tr>
<tr>
<th></th>
<th>id</th>
<th>name</th>
<th>sex</th>
<th>hobby</th>
<th>t</th>
<th><input type="button" value="添加" onclick="location='update.jsp'"></th>
</tr>
<c:forEach var="s" items="${studentList}">
<tr>
<th><input type="checkbox" value="${s.id}" class="ch"></th>
<th>${s.id}</th>
<th>${s.name}</th>
<th>${s.sex}</th>
<th>${s.hobby}</th>
<th>${s.t.tname}</th>
<th><input type="button" value="修改" onclick="location='update.jsp?id=${s.id}'">
<input type="button" value="删除" onclick="del(${s.id})"></th>
</tr>
</c:forEach>
<tr>
<th colspan="21">
<input type="button" value="首页" onclick="gopage(1)">
<input type="button" value="上页" onclick="gopage(${pu.prevPage})">
<input type="button" value="下页" onclick="gopage(${pu.nextPage})">
<input type="button" value="尾页" onclick="gopage(${pu.totalPage})">
${pu.cpage}/${pu.totalPage}页,共${pu.count}条数据
<input type="button" value="批删" onclick="dels()">
</th>
</tr>
<tr>
<th colspan="21">
<input type="button" onclick="allcheck()" value="全选">
<input type="button" value="不选" onclick="notcheck()">
<input type="button" value="反选" onclick="recheck()">
</th>
</tr>
</table>
</body>
</html>
最大的悲哀莫过于长大,从此笑不再纯粹,哭不再彻底。