Day17

bookList.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/header.jsp"%>
<br />
<hr />
<br />

<table border="1">
    <tr>
        <th>选择</th>
        <th>书名</th>
        <th>作者</th>
        <th>描述</th>
        <th>单价</th>
        <th>出版社</th>
        <th>所属分类</th>
        <th>图片</th>
        <th>操作</th>
    </tr>


    <c:forEach items="${page.records}" var="b" varStatus="vs">
        <tr class="${vs.index%2 ==0?'odd':'even' }">
            <td><input type="checkbox" name="ids">
            </td>
            <td>${b.name}</td>
            <td>${b.author}</td>
            <td>${b.description}</td>
            <td>${b.price}</td>
            <td>${b.publish}</td>
            <%-- <td>${cs.name}</td> --%>
            <td>${am:showCategoryName(b.categoryId)}</td>
            <td><img src="${basePath}images${b.path}/${b.photoName}"
                width="100px" height="100px"></td>
            <td><a href="${basePath}servlet/ControlServlet?op=editBookView&bookId=${b.id}">修改</a> 
            <a href="${basePath}servlet/ControlServlet?op=delBook&bookId=${b.id}">删除</a>
            </td>
        </tr>
    </c:forEach>
</table>
<%@ include file="/common/page.jsp"%>
</body>
</html>
View Code

categoryList.jsp

   
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/header.jsp"  %>
<br/>
<hr/>
<br/>

           <table border="1" >
               <tr>
                   <th>选择</th>
                   <th>分类名称</th>
                   <th>分类描述</th>
                   <th>操作</th>
               </tr>
               
               <!-- 属于jsp的标准标签库中的 循环标签 -->
                   <!-- items: 条、项 -->
               <c:forEach items="${cs}" var="c" >
                   <tr>
                       <td>
                           <input type="checkbox" name="ids" >
                       </td>
                       <td>
                           ${c.name }
                       </td>
                       <td>
                           ${c.description }
                       </td>
                       <td>
                           <a href="${basePath}servlet/ControlServlet?op=editCategoryView&categoryId=${c.id}">修改</a>
                           <a href="${basePath}servlet/ControlServlet?op=delCategory&categoryId=${c.id}">删除</a>
                       </td>
                   </tr>
               </c:forEach>
           </table>
  </body>
</html>
View Code

edit.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/header.jsp"  %>
<br/>
<hr/>
<br/>
    <!--${pageContext.request.contextPath}是为了获取这个路径:http://localhost:8888/bookstore -->
    <form action="${pageContext.request.contextPath}/servlet/ControlServlet?op=editCategory&id=${c.id}" method="post" >
        <table border="1">
            <!-- 第1行  -->
            <tr>
                <td>分类名称</td>
                <td><input type="text" name="name" value="${c.name}" ></td>
            </tr>
            <!-- 第2行  -->
            <tr>
                <td>分类描述</td>
                <td><textarea rows="3" cols="15" name="description"  >${c.description} </textarea>
                </td>
            </tr>
            <!-- 第3行  -->
            <tr>
                <td colspan="2"><input type="submit" value="编辑分类"></td>
            </tr>
        </table>
    </form>
</body>
</html>
View Code

editBook.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/header.jsp" %>
    <br/>
    <hr/>
    <br/>
    <form action="${basePath}servlet/ControlServlet?op=editBook&bookId=${b.id}" method="post" enctype="multipart/form-data" >
        <table border="1">
            <tr>
                <td>书名</td>
                <td><input type="text" name="name" value="${b.name}" ></td>
            </tr>
            <tr>
                <td>作者</td>
                <td><input type="text" name="author" value="${b.author}" ></td>
            </tr>
            <tr>
                <td>描述</td>
                <td><input type="text" name="description" value="${b.description}" ></td>
            </tr>
            <tr>
                <td>单价</td>
                <td><input type="text" name="price" value="${b.price}" ></td>
            </tr>
            <tr>
                <td>图片</td>
                <td><input type="file" name="photoname"></td>
            </tr>
            <tr>
                <td>图片预览</td>
                <td><img src="${basePath}images${b.path}/${b.photoName}" width="100px" height="100px" ></td>
            </tr>
            <tr>
                <td>出版社</td>
                <td><input type="text" name="publish"  value="${b.publish}" ></td>
            </tr>
            <tr>
                <td>分类</td>
                <td><select name="categoryId">
                    <c:forEach items="${cs}" var="c" >
                        <option value="${c.id}" >${c.name}</option>
                    </c:forEach>
                </select></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="修改图书"></td>
            </tr>
        </table>
    </form>
</body>
</html>
View Code

error.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 'error.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>
  
  <body>
   出错了 <br>
  </body>
</html>
View Code

header.jsp

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="am" uri="http://bianyige.com/javabs" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
pageContext.setAttribute("basePath", basePath);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'index.jsp' starting page</title>
    <link rel="stylesheet" href="css/main.css" type="text/css"></link>
  </head>
  
  <body>
 
 
<h3>     ${sessionScope.u.username},您好。欢迎来到xxx,您可以选择
</h3>
     
     
      <a href="${basePath}">网站主页</a>
     <a href="${basePath}addCategory.jsp">添加分类</a>
     <a href="${basePath}servlet/ControlServlet?op=findAllCategory">查询分类</a>
     <a href="${basePath}servlet/ControlServlet?op=addBookView">添加图书</a>
     <a href="${basePath}servlet/ControlServlet?op=showBook">查询图书</a>
     <a href="${basePath}showCart.jsp">购物车</a>
     
     
     <c:if test="${sessionScope.u==null}">
         <a href="${basePath}register.jsp">用户注册</a>
         <a href="${basePath}login.jsp">用户登录</a>
     </c:if>
     
     
     <c:if test="${sessionScope.u!=null}">
         <a href="${basePath}servlet/ControlServlet?op=logout">用户注销</a>
      </c:if>
View Code

 

posted @ 2022-01-22 20:14  灰幕  阅读(23)  评论(0)    收藏  举报