1 页面
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
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>管理员首页</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">
-->
<!-- 引用Bootstrap -->
<link href="<%=basePath%>/boostrap/css/bootstrap.min.css"
rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row clearfix">
<div class="col-md-12 column">
</div>
</div>
<div class="row clearfix">
<div class="col-md-12 column">
<c:choose>
<c:when test="${listNotexamined_info != null }">
<h3>
<c:out value="${listNotexamined_info }"></c:out>
</h3>
</c:when>
<c:otherwise>
<c:if test="${newsList != null && newsList.size() != 0 }">
<form action="root/publishAllNews" method="post">
<table class="table">
<thead>
<tr>
<!-- 全选按钮 -->
<th><input name="checkAll" id="checkAll" type="checkbox" />
全选</th>
<th>标题</th>
<th>时间</th>
<th>城市</th>
<th>类别</th>
<th>编辑</th>
<th>是否审核</th>
<th></th>
</tr>
</thead>
<tbody>
<c:forEach items="${newsList }" var="news">
<tr>
<!-- 逐个选择按钮 -->
<td><input name="newsId" type="checkbox"
value=<c:out value="${news.id }"/> /></td>
<!--
省略。。。。。。
-->
<td><button id="<c:out value="${news.id }"/>"
class="btn btn-default" onclick="publicNews(this)">发布</button></td>
</tr>
</c:forEach>
</tbody>
</table>
<hr/>
<p align="right">
<input type="submit" value="发布选中" class="btn btn-default" />
</p>
</form>
</c:if>
</c:otherwise>
</c:choose>
</div>
</div>
</div>
</body>
2 Js
$(function(){
//全选和全反选
$("#checkAll").click(function(){
var isChecked = $(this).prop("checked");
$("input[name='newsId']").prop("checked", isChecked);
});
});
3 后台
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String[] newsIds = request.getParameterValues("newsId");
}
4界面
![145415_Za7G_2328736.png](https://i-blog.csdnimg.cn/blog_migrate/2819940915e2618756510a1c0ac1f934.png)