JSP图书管理系统
index.jsp
<%@page import="bean.Book"%> <%@page import="dao.BookDao"%> <%@ 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>图书管理系统</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"> window.onload = function() { doubleBgColor(document.getElementById("record_table","#e5f1f4","#f8fbfc")); } function doubleBgColor(Table,Bg1,Bg2) { for (var i=0;i<Table.rows.length;i++){ Table.rows[i].bgColor=i%2?Bg2:Bg1; } } </script> </head> <body> <% BookDao bd = new BookDao(); // String uname = (String) session.getAttribute("name"); List<Book> list = bd.getReceive(/* uname */); %> <div align="center"> <h1>图书信息</h1> <table border="3" id="record_table"> <tr> <td>图书名称</td> <td>图书作者</td> <td>购买时间</td> <td>图书分类</td> <td>操作</td> </tr> <%for(int i=0;i<list.size();i++){ %> <tr> <td><%=list.get(i).getName() %></td> <td><%=list.get(i).getAuthor() %></td> <td><%=list.get(i).getTime() %></td> <td><%int x=list.get(i).getType(); if(x==0){ %> <p>选择所属分类:<p> <% }if(x==1){ %> 计算机/软件 <%}if(x==2){ %> 小说/文摘 <%}if(x==3){ %> 杂项 <%} %> </td> <td><a href="DelServlet?id=<%=list.get(i).getId()%>">删除</a></td> </tr> <%} %> <!-- <tr><td><a href="add.jsp">新增图书信息</a></td></tr> --> </table> <a href="add.jsp">新增图书信息</a> </div> </body> <script type="text/javascript"> $(document).ready(function () { $("#table tr:even").not("tr:first").css("background","#80ffff"); $("#table tr:eq(0)").css("background","#ffcccc"); $("#table tr:eq(1)").css("background","#ffcc99"); }) $(".shanchu").click(function(){ event.preventDefault(); conn = confirm("是否删除"); if(conn == true){ var id = $("#id2").val(); $.ajax({ url:"DelServlet", type:"post", data:{"id":id}, success:function(result){ if(result == "true"){ alert("删除成功!"); } } }) } }) </script> </html>




浙公网安备 33010602011771号