<h3>新闻发布系统>>新闻管理>>查询新闻</h3> <center> <form action="SelectNews" method="post"> 请输入查询条件:<input type="text" name="key"> <input type="submit" value="查询"> </form><br> <table border="1" width="70%" cellpadding="0" cellspacing="0"> <tr align="center"> <td>编号</td> <td>标题</td> <td>类型</td> <td>发布人</td> <td>发布日期</td> <td>状态</td> <td>是否头条</td> <td colspan="4">操作</td> </tr> <c:forEach items="${newsList }" var="news"> <tr align="center"> <td><input type="checkbox" name="newsIds" value="${news.nid}"></td> <td>${news.nid }</td> <td>${news.title }</td> <td>${news.type }</td> <td>${news.userName }</td> <td>${news.pubtime }</td> <td> <c:choose> <c:when test="${news.state==0 }">待审核</c:when> <c:when test="${news.state==1 }">通过</c:when> <c:otherwise>未通过</c:otherwise> </c:choose> </td> <td> <c:choose> <c:when test="${news.top==0 }">否</c:when> <c:otherwise>是</c:otherwise> </c:choose> </td> <td>${news.top==0?"是":"否" }</td> <td> <a href="NewsDetail?nid=${news.nid }&op=show">查看</a> <c:if test="${user.rule==0 || user.uid ==news.uid }"> <a href="NewsDetail?nid=${news.nid }&op=update">修改</a> </c:if> <c:if test="${user.rule==0 }"> <a href="newsDelete.jsp?nid=${news.nid }"> 删除</a> </c:if> <c:if test="${user.rule==0 }"> 审核</c:if> </td> </tr> </c:forEach> </table> <button type="button" ><a href="javascript:void(0)" onclick="banchDelete()">批量删除</a></button> </center> </body> <script type="text/javascript"> function banchDelete(){ var idsArray = document.getElementsByName("newsIds"); var nidArray=[]; for(k in idsArray){ if(idsArray[k].checked){ nidArray.push(idsArray[k].value); } } if(nidArray.length==0){ alert("请选择要删除的新闻"); return } window.location.href="./newsBanchDelete.jsp?nids="+nidArray.join(","); } </script>这段代码优化使user.rule=0的用户才能看见批量删除的按钮
时间: 2023-08-14 18:21:15 浏览: 126
详解自动生成博客目录案例
可以在代码中加入以下判断语句,只有当用户的rule为0时才会显示批量删除按钮:
```html
<c:if test="${user.rule==0}">
<button type="button"><a href="javascript:void(0)" onclick="banchDelete()">批量删除</a></button>
</c:if>
```
其中,`${user.rule}`表示当前用户的权限等级。
阅读全文