您现在的位置:首页 >> 前端 >> 内容

文章标题

时间:2016/12/17 9:31:00 点击:

  核心提示:update.jsp这里写代码片%@ page language=java import=java.util.* pageEncoding=UTF-8%%@ taglib uri=https://ja...

update.jsp这里写代码片

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="https://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 'update.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">
    -->
 <script type="text/javascript" src="lib/jquery-1.11.3.js"></script>
  <script type="text/javascript">
   function check(){
   // var id= $("#id").val();
    var username= $("#username").val();
    var class1= $("#class1").val();
     var xi= $("#xi").val();
    var zhuanye= $("#zhuanye").val();
    //  if(id==""){
    //  $("#s_id").html("*学号不能为空").css("color","red");
    //  event.preventDefault();
  //  }

     if(username==""){
      $("#s_username").html("*姓名不能为空").css("color","red");
      event.preventDefault();
     }

     if(class1==""){
     $("#s_class").html("*班级不能为空").css("color","red");
      event.preventDefault();
     }
       if(xi=="系"){
     $("#s_xi").html("*请完善信息").css("color","red");
       event.preventDefault();
     }

      if(zhuanye=="专业"){
     $("#s_xi").html("*请完善信息").css("color","red");
       event.preventDefault();
     }
   }








      $(function(){
       $("#xi").bind("change",function(){
        var xi= $("#xi").val();
        switch (xi) {
        case "信息工程系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
              $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>软件外包</option>");
             $("#zhuanye").append("<option>华为IT</option>");
             $("#zhuanye").append("<option>软件技术</option>");
             $("#zhuanye").append("<option>应用设计</option>");
            break;

        case "艺术传媒系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>人物形象设计</option>");
             $("#zhuanye").append("<option>装饰艺术设计</option>");
             $("#zhuanye").append("<option>广告设计与制作</option>");
             $("#zhuanye").append("<option>应用艺术设计</option>");

            break;


        case "经济管理系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>会计电算化</option>");
             $("#zhuanye").append("<option>国民经济管理</option>");
             $("#zhuanye").append("<option>现代经济管理</option>");
             $("#zhuanye").append("<option>市场营销</option>");

            break;
            case "机械工程系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>机电一体化</option>");
             $("#zhuanye").append("<option>机械制造</option>");
             $("#zhuanye").append("<option>机械设计</option>");
             $("#zhuanye").append("<option>机械自动化</option>");

            break;

        }


       })



  //      $("#id").blur(function(){
    //var id=$("#id").val();
    //if(id=="" || id.length<4){
    //$("#s_id").html("*学号不能少于4位!").css("color","green");
    // }else {
    //  $("#s_id").html("");
    //   }
   //  })


        $("#username").blur(function(){
          var username =$("#username").val();
         if(username=="" ){
         $("#s_username").html("*姓名不能为空").css("color","green");
          }  else{
             $("#s_username").html("").css("color","blue");
              }
         })



   $("#xi").bind("blur",function(){
         var sheng=$("#xi").val();
         var zhuanye=$("#zhuanye").val();
          if(sheng=="系"){
          $("#s_xi").text("请选择系");
         }
         else if(zhuanye=="专业"){
          $("#s_xi").text("请选择专业");
         }
         else {
        $("#s_xi").text("");
         }
       })
          $("#zhuanye").bind("blur",function(){
         var zhuanye=$("#zhuanye").val();
           if(zhuanye=="专业"){
          $("#s_xi").text("请选择专业");
         }
         else {
        $("#s_xi").text("");
         }
       })

       $("#class1").bind("blur",function(){
         var class1=$("#class1").val();
           if(class1==""){
          $("#s_class").text("请输入班级");
         }
         else {
        $("#s_class").text("");
         }
       });
       })
  </script>
  </head>

  <body  background="img/0517.jpg">
    <center><h1>修改</h1>
     <%
        String err1=(String)request.getAttribute("err1");
          if(err1!=null){
              out.print("<h2 style='color:red;'>"+err1+"</h2>");
       }
   // int id =Integer.parseInt(request.getParameter("id"));
       %>
    <form action="updateServlet" method="post">
      <table cellspacing="20px">
              <tr >
             <td  align="right">学号:</td>
            <td><input type="text" name="id" id="id" value="${param.id }" disabled="disabled"  onkeyup="value=value.replace(/[^(\d)]/g,'')"  /></td>
            <td><span id="s_id"></span></td>
          </tr>
            <c:set var="idd" scope="session" value="${param.id }"></c:set>

          <tr>
           <td  align="right">姓名:</td>
            <td><input type="text" name="username" id="username" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')"  /></td>
             <td><span id="s_username"></span></td>
          </tr>



          <tr>
           <td  align="right">性别:</td>
            <td><input type="radio" name="sex" value="男" checked="checked"/>男
            <input type="radio"  name="sex"    value="女" />女</td>
          </tr>


          <tr>
           <td  align="right">所在省市:</td>
            <td>
              <select name="xi" id="xi" style="width:90px">
                   <option value="系">系</option>
                    <option value="信息工程系">信息工程系</option>
                    <option value="艺术传媒系">艺术传媒系</option>
                    <option value="经济管理系">经济管理系</option>
                    <option value="机械工程系">机械工程系</option>
                  </select>
                 <select name="zhuanye" id="zhuanye" style="width:110px">
                   <option value="专业">专业</option>

                 </select>
              <td  ><span id="s_xi"></span></td>
            </td>
          </tr>

          <tr>
           <td  align="right">班级:</td>
            <td>  <input type="text" name="class"  id="class1"/></td>
             <td><span id="s_class"></span></td>
          </tr>
           <tr align="center" >

            <td colspan="3"> <input type="submit" onclick="check()" value="修改" style="width: 300px;height:50px ;background-color: #69b946;color: #fff;"/>
</td>
          </tr>

        </table>
      </form>


    </center>
  </body>
</html>

studentManager.jsp

<style type="text/css">


a:link{
    text-decoration: none;
    color: blue;
}
a:visited{
    color: blue;
}
a:hover{
    color: blue;
}
a:active{
    color: red;
}


 #t1{
 border-top: double;
 border-bottom: double;
 background: infobackground;
 }
 #t2{

 border-bottom: groove;
 background: azure  ;
  }
   #t3{

 border-bottom: groove;
  background: azure;
  }

 #d1{
  position: relative;;
 margin-left: 90%;
 }
  #d2{
  position: relative;;
 margin-left: 92.5%;
 }
 #c1{
  position: relative;;
 margin-left: 28.5%;
 }
  </style>
  </head>
   <script type="text/javascript" src="lib/jquery-1.11.3.js"></script>
  <script type="text/javascript">
      $(function(){
        $("#xi").bind("change",function(){
        var xi= $("#xi").val();
        switch (xi) {
        case "信息工程系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>软件外包</option>");
             $("#zhuanye").append("<option>华为IT</option>");
             $("#zhuanye").append("<option>软件技术</option>");
             $("#zhuanye").append("<option>应用设计</option>");
            break;

        case "艺术传媒系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>人物形象设计</option>");
             $("#zhuanye").append("<option>装饰艺术设计</option>");
             $("#zhuanye").append("<option>广告设计与制作</option>");
             $("#zhuanye").append("<option>应用艺术设计</option>");

            break;


        case "经济管理系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>会计电算化</option>");
             $("#zhuanye").append("<option>国民经济管理</option>");
             $("#zhuanye").append("<option>现代经济管理</option>");
             $("#zhuanye").append("<option>市场营销</option>");

            break;
            case "机械工程系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>机电一体化</option>");
             $("#zhuanye").append("<option>机械制造</option>");
             $("#zhuanye").append("<option>机械设计</option>");
             $("#zhuanye").append("<option>机械自动化</option>");

            break;

        }


       })



       })


        function dele(){
        var my=confirm("确认删除吗?");
                if(my!=true)
                {
                        event.preventDefault();
                }
                else{

                }

         }
  </script>


  <body background="img/12111.png">

    <p id="d1">当前账号:${sessionScope.username }</p>
    <p id="d2"><a href="invalidate.jsp">点击注销</a></p>
    <center>

      <form action="selectServlet" method="post">
     <img src="img/st.jpg" width="350px" height="80px" ></img>
       <h1><img src="img/logo.jpg" width="25px" height="25px"></img>大肥羊学生信息管理系统</h1>
         选择系: <select name="xi" id="xi">
                     <option value="系"  style="width:90px">系</option>
                    <option value="信息工程系">信息工程系</option>
                    <option value="艺术传媒系">艺术传媒系</option>
                    <option value="经济管理系">经济管理系</option>
                    <option value="机械工程系">机械工程系</option>
                  </select>
                 选择专业:<select name="zhuanye" id="zhuanye"  style="width:110px">
                   <option value="专业">专业</option>

                 </select>


                                    按<input type="radio" name="radio" value="r1">编号
                  <input type="radio" name="radio"  value="r2">姓名
                           关键字<input type="text" name="guanjian" style="width:60px ">
                            &nbsp;
                     <input type="submit"value="查询" id="bt1">
                     <input type="radio"  name="check">全部
                   <a href="cutPage">分页查询</a>
                     <a href="add.jsp">添加</a>
                     </form> 





               <h2>查询结果</h2>
             <table  id="t1"  cellspacing="20px">
            <tr align="center"  width="100px">
                <td width="100px"  >编号</td>
                <td width="100px">姓名</td>
                <td width="100px">性别</td>
                <td width="100px">系</td>
                <td width="100px">专业</td>
                <td width="100px"> 班级</td>
                <td width="100px">操作</td>
                 </tr>
            </table >


           <c:forEach items="${list}" var="select">
              <table  cellspacing="18px" id="t2">
                <tr align="center"  >
                    <td width="100px">
                        <c:out value="${select.id}" />
                    </td>
                    <td width="100px">
                        <c:out value="${select.name}" />
                    </td>
                    <td width="100px">
                        <c:out value="${select.sex}" />
                    </td>
                    <td width="100px">
                        <c:out value="${select.xi}" />
                    </td>
                    <td width="100px">
                        <c:out value="${select.zhuanye}" />
                    </td>
                    <td width="100px">
                        <c:out value="${select.class1}" />
                    </td>

                    <td width="100px">

                        <a href="update.jsp?id=${select.id }"><button>修改</button></a>
                        <a href="deleteServlet?id=${select.id }"><button onclick="dele()">删除</button></a>
                    </td>
                </tr>
                 </table>
            </c:forEach>      






            <%--分页 --%>
         <table cellspacing="18px" id="t3">


            <c:forEach items="${requestScope.CutPage.data }" var="st" varStatus="num">
                <c:choose>
                    <c:when test="${not num.last }">
                        <tr align="center">
                    <td width="100px">${st.id }</td>
                    <td width="100px">${st.name }</td>
                    <td width="100px">${st.sex }</td>
                    <td width="100px">${st.xi }</td>
                    <td width="100px">${st.zhuanye }</td>
                    <td width="100px" align="center">${st.class1 }</td>
                    <td width="100px">
                        <a href="update.jsp?id=${st.id }"><button>修改</button></a>
                        <a href="deleteServlet?id=${st.id }"><button onclick="dele()">删除</button></a>
                    </td>
                </tr>
                    </c:when>
                    <c:otherwise>
                        <tr align="center">
                    <td width="100px">${st.id }</td>
                    <td width="100px">${st.name }</td>
                    <td width="100px">${st.sex }</td>
                    <td width="100px">${st.xi }</td>
                    <td width="100px">${st.zhuanye }</td>
                    <td width="100px" >${st.class1 }</td>
                    <td width="100px">

                        <a href="update.jsp?id=${st.id }"><button>修改</button></a>
                        <a href="deleteServlet?id=${st.id }"><button onclick="dele()">删除</button></a>
                    </td>
                </tr>
                <tr>
                    <td colspan="7" align="center">
                        <a href="cutPage?currentPage=1">首页</a>
                        <a href="cutPage?currentPage=${requestScope.CutPage.currentPage - 1}">上一页</a>
                        <a>当前第${requestScope.CutPage.currentPage }页</a>
                        <a href="cutPage?currentPage=${requestScope.CutPage.currentPage + 1}">下一页</a>
                        <a href="cutPage?currentPage=${requestScope.CutPage.totalPageCount }">尾页</a>
                        <a>共${requestScope.CutPage.totalPageCount }页</a>
                    </td>
                </tr>
                    </c:otherwise>

                </c:choose>
             </c:forEach>
         </table>

      </center>



  </body>

login.jsp`

<style type="text/css">

        img{
            cursor: pointer;
        }
      .c1{
        margin-top:-40px;

      }

     .c_all{
      font-size: 18px;
      color:#38f; 
      font-family: inherit;
     }

.btn1 {
    color: white;
    background-color: #38f;
    width: 102px;
    height: 38px;
    font-size: 16px;
    border: 0;
}

/*轮播*/
    #flash{
            position: relative;/*相对*/
             width: 990px;  
             height: 270px;

             margin: 70px auto;
            }
            #flash ul li{
                position: absolute;/*绝对*/
                top: 20px;
                list-style: none;
                width: 540px;
                height: 230px;
                z-index: 1;/*层级*/
                background: #000;
            }
            #flash ul li img{
                opacity: 0.5;/*透明度*/

            }
            #flash ul li.first{
                z-index: 10;
                left: 175px;/*距离参考物左端的距离*/
                top: 0px;
                width: 640px;
                height: 270px;
            }
            #flash ul li.first img{
                opacity: 1;
            }
            #flash ul li.second{
                left: 0px;
                 z-index: 3;
            }
            #flash ul li.last{
                left: 450px;
                z-index: 5;
            }
            #flash ul li.center{
                left: 225px;

            }
            .btn img{

                position: absolute;

                top: 50%;
                z-index: 10;
                margin-top: -23px;
            }
            .btn img.left{
                left: 65px;
            }
            .btn img.rihgt{
                right: 65px;
            }


    </style>
  </head>
  <script type="text/javascript" src="lib/jquery-1.11.3.js"></script>
  <script type="text/javascript">
    function refresh(){
        //alert("验证码被点击");
        var time = new Date();
        var img = document.getElementById("validateCode");
        //alert(img);
        img.src = "validateCodeServlet?time="+time.getTime();
    }




    function check(){
     var username=$("#username").val();
     var password=$("#password").val();
     var vali=$("#validate").val();

     if(username==""){
       $("#s2").html("*账号不能为空").css("color","blue");
        event.preventDefault();
     }

       if(password==""){
       $("#s3").html("*密码不能为空").css("color","blue");
        event.preventDefault();
     }

     if(vali==""){
       $("#s1").html("*验证码不能为空").css("color","blue");
        event.preventDefault();
     }



    }




    $(function(){
    $("#validate").blur(function(){
          var validate =$("#validate").val();
         if(validate!="" ){
         $("#s1").html("") ;
          }  else{
             $("#s1").html("*验证码不能为空").css("color","red");
              }
         })

         $("#username").blur(function(){
          var username =$("#username").val();
         if(username!="" ){
         $("#s2").html("") ;
          }  else{
             $("#s2").html("*账号不能为空").css("color","red");
              }
         })


         $("#password").blur(function(){
          var password =$("#password").val();
         if(password!="" ){
         $("#s3").html("") ;
          }  else{
             $("#s3").html("*密码不能为空").css("color","red");
              }
         })

         })

  </script>

  <body  background="img/012.jpg">
  <%


     String err=(String)request.getAttribute("err");

            if(err!=null){
             out.print("<center><h1 style='color:red;'>"+err+"</h1></center>");
            }

              String err2=(String)request.getAttribute("err2");
          if(err2!=null){
              out.print("<center><h2 style='color:red;'>"+err2+"</h2></center>");
       }


            //获取cookie 取出对应的内容填入表单中
             String username="";
             String password="";
             Cookie[] cookies= request.getCookies();
             if(cookies!=null){
                 for(Cookie c:cookies){
                        //遍历cookie 获得用户名
                    if(c.getName().equals("username")){
                 username= URLDecoder.decode(c.getValue(), "utf-8");
                // username= c.getValue();
                    }
                          //遍历cookie 获得用户名
                    if(c.getName().equals("password")){
                 password= URLDecoder.decode(c.getValue(), "utf-8"); 
                  //password=c.getValue();
                    }
                 }
           }





   %>
    <p id="flash">
            <ul>
                <li class="first">
                    <img src="img/7.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="second">
                    <img src="img/2.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="center">
                    <img src="img/3.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="center">
                    <img src="img/4.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="center">
                    <img src="img/5.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="center">
                    <img src="img/6.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="center">
                    <img src="img/9.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="center">
                    <img src="img/8.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="center">
                    <img src="img/1.jpg" width="100%"  height="100%"/>
                 </li>
                 <li class="last">
                    <img src="img/10.jpg" width="100%"  height="100%"/>
                 </li>
            </ul>
            <p class="btn">
                <img class="left" src="img/left.png" />
                <img class="rihgt" src="img/right.png" />
            </p>
         </p>



        <center>
    <form action="loginServlet" method="post">
      <table  width="390px" height="300px" class="c1"  style="border-radius:10px" border="1px">
    <tr>
    <td> 


    <%
     String errfliter=(String)request.getAttribute("errfliter");

            if(errfliter!=null){
             out.print("<center><h2 style='color:red;'>"+errfliter+"</h2></center>");
            }
     %>


     <center> <h2>管理员登录</h2></center>
    <table >

       <tr>
         <td class="c_all">用户名:</td>
         <td>
          <input type="text" name="username" id="username"  value="<%=username %>">
         </td>

        <td><span id="s2">*请输入账号</span></td>
       </tr>

     <tr>
         <td class="c_all" align="right">密码:</td>
         <td>
          <input type="password" name="password" id="password"  value="<%=password %>">
         </td>

          <td><span id="s3">*请输入密码</span></td>
       </tr>

       <tr>
         <td class="c_all" ><span id="s5">验证码:</span></td>
        <td>
         <input type="text" name="validate" id="validate" placeholder="不区分大小写">
       </td>
        <td  ><span id="s1">*请输入验证码</span></td>
       </tr>

       <tr>
       <td></td>

        <td>
           <img src="validateCodeServlet" height="30" onclick="refresh()" title="点击刷新" id="validateCode">
        </td>

       </tr>
       <tr>
        <td>

        </td>
        <td>
         <input type="checkbox" name="save">记住密码<br/>
        </td>
       </tr>
        <%--   <tr>
         <td align="center" colspan="2">
          <button onclick="check()" class="btn1">登录</button>
         </td>
          <td align="left">
         <a href="register.jsp">注册</a>
         </td>
        </tr>
        --%>
        </table> 
       &nbsp; &nbsp; &nbsp; &nbsp; 
        <button onclick="check()" class="btn1">登录</button>&nbsp; &nbsp; 
        <a href="register.jsp">注册</a>



          </td>
       </tr>
   </table>  

    </form>
    </center>
    <script src="js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
         <script type="text/javascript">
          $(".left").click(function(){
              arrts(false);

          });
           $(".rihgt").click(function(){
              arrts(true);

          });

          var arrWidth =[],arrHeihgt=[],arrLeft=[],arrZindex=[],arrTop=[],arrT=[];
          var $li =$("#flash ul li");
          var n=0;
          function arrts( dir){
            for( var i=0;i<10;i++){
                //循环获取每个li的值病添加到数组里面
                arrWidth[i]=$li.eq(i).css("width");
                arrHeihgt[i]=$li.eq(i).css("height");
                arrLeft[i]=$li.eq(i).css("left");
                arrZindex[i]=$li.eq(i).css("z-index");
                arrTop[i]=$li.eq(i).css("top");
                arrT[i]=$li.eq(i).find("img").css("opacity")
            }
            for (var i = 0; i < 10; i++) {
                if (dir) {//为true 往右
                    if(i==9){
                        n=0;

                    }else{
                        n=i+1;
                    }

                } else{
                    if(i==0){
                    n=9;

                    }else{
                        n=i-1;  
                    }

                }
                $li.eq(i).css("z-index",arrZindex[n])
                $li.eq(i).find("img").css("opacity",arrT[n])
                //animate ({属性},时间)  自定义动画
                 $li.eq(i).animate({
                    "width":arrWidth[n],
                    "height":arrHeihgt[n],
                    "left":arrLeft[n],
                    "top":arrTop[n]
                 },1000);
            }
          }

         </script>
  </body>

invalidate

</head>

  <body>

             <% session.invalidate();//销毁session  request.getRequestDispatcher("login.jsp").forward(request, response);%>
  </body>

cutpage.jsp

</head>

  <body>
        <center>
            <a href="cutPage">分页查询</a>

        <h4>显示查询结果</h4>
        <table>
            <tr>
                <td>编号</td>
                <td>姓名</td>
                <td>性别</td>
                <td>系</td>
                <td>专业</td>
                <td>班级</td>
                <td>操作</td>
            </tr>

            <c:forEach items="${sessionScope.CutPage.data }" var="st" varStatus="num">
                <c:choose>
                    <c:when test="${not num.last }">
                        <tr>
                    <td>${st.id }</td>
                    <td>${st.name }</td>
                    <td>${st.sex }</td>
                    <td>${st.xi }</td>
                    <td>${st.zhuanye }</td>
                    <td>${st.class1 }</td>
                    <td>
                        <a href="111.jsp?id=${st.id }">修改</a>
                        <a href="222.jsp">删除</a>
                    </td>
                </tr>
                    </c:when>
                    <c:otherwise>
                        <tr>
                    <td>${st.id }</td>
                    <td>${st.name }</td>
                    <td>${st.sex }</td>
                    <td>${st.xi }</td>
                    <td>${st.zhuanye }</td>
                    <td>${st.class1 }</td>
                    <td>
                        <a href="111.jsp?id=${st.id }">修改</a>
                        <a href="222.jsp">删除</a>
                    </td>
                </tr>
                <tr>
                    <td colspan="7">
                        <a href="cutPage?currentPage=1">首页</a>
                        <a href="cutPage?currentPage=${sessionScope.CutPage.currentPage - 1}">上一页</a>
                        <a>当前第${sessionScope.CutPage.currentPage }页</a>
                        <a href="cutPage?currentPage=${sessionScope.CutPage.currentPage + 1}">下一页</a>
                        <a href="cutPage?currentPage=${sessionScope.CutPage.totalPageCount }">尾页</a>
                        <a>共${sessionScope.CutPage.totalPageCount }页</a>
                    </td>
                </tr>

                    </c:otherwise>

                </c:choose>

            </c:forEach>

        </table>

        </center>

  </body>

add.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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 'add.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">
    -->

  </head>
    <script type="text/javascript" src="lib/jquery-1.11.3.js"></script>
  <script type="text/javascript">
   function check(){
    var id= $("#id").val();
    var username= $("#username").val();
    var class1= $("#class1").val();
     var xi= $("#xi").val();
    var zhuanye= $("#zhuanye").val();
      if(id==""){
      $("#s_id").html("*学号不能为空").css("color","red");
      event.preventDefault();
     }

     if(username==""){
      $("#s_username").html("*姓名不能为空").css("color","red");
      event.preventDefault();
     }

     if(class1==""){
     $("#s_class").html("*班级不能为空").css("color","red");
      event.preventDefault();
     }
       if(xi=="系"){
     $("#s_xi").html("*请完善信息").css("color","red");
       event.preventDefault();
     }

      if(zhuanye=="专业"){
     $("#s_xi").html("*请完善信息").css("color","red");
       event.preventDefault();
     }
   }








      $(function(){
       $("#xi").bind("change",function(){
        var xi= $("#xi").val();
        switch (xi) {
        case "信息工程系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
              $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>软件外包</option>");
             $("#zhuanye").append("<option>华为IT</option>");
             $("#zhuanye").append("<option>软件技术</option>");
             $("#zhuanye").append("<option>应用设计</option>");
            break;

        case "艺术传媒系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>人物形象设计</option>");
             $("#zhuanye").append("<option>装饰艺术设计</option>");
             $("#zhuanye").append("<option>广告设计与制作</option>");
             $("#zhuanye").append("<option>应用艺术设计</option>");

            break;


        case "经济管理系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>会计电算化</option>");
             $("#zhuanye").append("<option>国民经济管理</option>");
             $("#zhuanye").append("<option>现代经济管理</option>");
             $("#zhuanye").append("<option>市场营销</option>");

            break;
            case "机械工程系":
             $("#zhuanye").empty();//先清空之前的市
             //添加对省份的城市
             $("#zhuanye").append("<option>专业</option>");
             $("#zhuanye").append("<option>机电一体化</option>");
             $("#zhuanye").append("<option>机械制造</option>");
             $("#zhuanye").append("<option>机械设计</option>");
             $("#zhuanye").append("<option>机械自动化</option>");

            break;

        }


       })



        $("#id").blur(function(){
    var id=$("#id").val();
    if(id=="" || id.length<4){
    $("#s_id").html("*学号不能少于4位!").css("color","green");
     }else {
        $("#s_id").html("");
         }
     })


        $("#username").blur(function(){
          var username =$("#username").val();
         if(username=="" ){
         $("#s_username").html("*姓名不能为空").css("color","green");
          }  else{
             $("#s_username").html("").css("color","blue");
              }
         })



   $("#xi").bind("blur",function(){
         var sheng=$("#xi").val();
         var zhuanye=$("#zhuanye").val();
          if(sheng=="系"){
          $("#s_xi").text("请选择系");
         }
         else if(zhuanye=="专业"){
          $("#s_xi").text("请选择专业");
         }
         else {
        $("#s_xi").text("");
         }
       })
          $("#zhuanye").bind("blur",function(){
         var zhuanye=$("#zhuanye").val();
           if(zhuanye=="专业"){
          $("#s_xi").text("请选择专业");
         }
         else {
        $("#s_xi").text("");
         }
       })

       $("#class1").bind("blur",function(){
         var class1=$("#class1").val();
           if(class1==""){
          $("#s_class").text("请输入班级");
         }
         else {
        $("#s_class").text("");
         }
       });
       })
  </script>
  <body  background="img/0517.jpg">

            <center>
            <%
              String err1=(String)request.getAttribute("err1");
          if(err1!=null){//说明request 包含错误信息 将错误信息显示到页面中
              out.print("<h2 style='color:red;'>"+err1+"</h2>");
       }
             %>
             ${param.err }
              <h1>添加</h1>
             <form action="addServlet" method="post">
              <table cellspacing="20px">
              <tr >
             <td  align="right">学号:</td>
            <td><input type="text" name="id" id="id"  onkeyup="value=value.replace(/[^(\d)]/g,'')"  /></td>
            <td><span id="s_id"></span></td>
          </tr>

          <tr>
           <td  align="right">姓名:</td>
            <td><input type="text" name="username" id="username" onkeyup="value=value.replace(/[^\u4E00-\u9FA5]/g,'')"  /></td>
             <td><span id="s_username"></span></td>
          </tr>



          <tr>
           <td  align="right">性别:</td>
            <td><input type="radio" name="sex" value="男" checked="checked"/>男
            <input type="radio"  name="sex"    value="女" />女</td>
          </tr>


          <tr>
           <td  align="right">所在省市:</td>
            <td>
              <select name="xi" id="xi" style="width:90px">
                   <option value="系">系</option>
                    <option value="信息工程系">信息工程系</option>
                    <option value="艺术传媒系">艺术传媒系</option>
                    <option value="经济管理系">经济管理系</option>
                    <option value="机械工程系">机械工程系</option>
                  </select>
                 <select name="zhuanye" id="zhuanye" style="width:110px">
                   <option value="专业">专业</option>

                 </select>
              <td  ><span id="s_xi"></span></td>
            </td>
          </tr>

          <tr>
           <td  align="right">班级:</td>
            <td>  <input type="text" name="class"  id="class1"/></td>
             <td><span id="s_class"></span></td>
          </tr>
           <tr align="center" >

            <td colspan="3"> <input type="submit" onclick="check()" value="添加" style="width: 300px;height:50px ;background-color: #69b946;color: #fff;"/>
</td>
          </tr>

        </table>
      </form>
            </center>
  </body>
</html>

Tags:文章 章标 标题   
作者:网络 来源:一只默默撸代码的忆寒