ssm整合JSP查询界面

来源:互联网 发布:谷歌娘语音软件 编辑:程序博客网 时间:2024/06/06 18:05
<%@ 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>
    <script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
     <script type="text/javascript">
         $(function(){
         $("#selectAll").click(function(){
                  $("input[type=checkbox]:gt(0)").attr("checked","checked");
                  });
                  $("#deleteAll").click(function(){
                  var array=new Array();
                  $("input[type=checkbox]:gt(0):checked").each(function(){
                      array.push($(this).parent().next().text());
                  });
                  console.log(array);
                  location.href="${pageContext.request.contextPath}/user/batchDelete?ids="+array;
              });
             $("#getUserList").click(function(){
                 var name=$(this).prev().val();
                 
                 if($("#name").val==null&&$("#name").val==''){
                 alert("ai");
                 location.href="${pageContext.request.contextPath}/user/getUserList?name"+name;
                 }else{
                 location.href="${pageContext.request.contextPath}/user/getUserList";
                 }
                 
             });
             $("#import").click(function(){
                 var array=$("input[type=checkbox]:checked");
                 if(array.length==0){
                     alert("请选择您要导出的数据...");
                 }else{
                     var ids=new Array();
                     array.each(function(){
                         ids.push($(this).parent().next().text());
                     });
                     $.post("${pageContext.request.contextPath}/employee/queryByIds","ids="+ids,function(d){
                         if(d=="ok"){
                             alert("数据导入成功!");
                         }else{
                             alert("数据导入失败!");
                         }
                         location.reload();
                     },"json");
                 }
             });
         });
     </script>
  </head>
 
  <body>
      <div>
          姓名:<input type="text" name="name" id="name"/><input type="button" value="查询" id="getUserList"/>
          &nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="导出" id="import"/>
      </div>
    <table border="1" width="80%" bgcolor="palegreen">
        <tr>
            <th>选择</th>
            <th>序号</th>
            <th>姓名</th>
            <th>薪资</th>
            <th>职位</th>
            <th>部门</th>
            <th>操作</th>
        </tr>
        <c:forEach items="${requestScope.list }" var="e">
            <tr>
                <td><input type="checkbox"></td>
                <td>${e.id }</td>
                <td>${e.name }</td>
                <td>${e.salary }</td>
                <td>${e.position }</td>
                <td>${e.department.name }</td>
                <td><a href="${pageContext.request.contextPath }/user/selectdepart.do">添加</a> </td>
            </tr>
        </c:forEach>
    </table>
    <input type="button" value="批量删除" id="deleteAll"/>
  </body>
</html>

原创粉丝点击