![]() |
#2
疯狂的小a2018-05-03 20:58
![]() <%@ page language="java" contentType="text/html; charset=UTF-8" 首先可以在books展示页面分别添加两个a标签用于添加和修改pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java. %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>展示书本信息</title> </head> <body> <span style="color: red;">${tip}</span> <table border="1"> <tr> <th>编号</th> <th>封面</th> <th>书名</th> <th>作者</th> <th>价格</th> <th>操作</th> </tr> <c:forEach items="${books}" var="book"> <tr> <td>${book.id }</td> <td><img src="${pageContext.request.contextPath }/images/${book.image}" /></td> <td>${book.name }</td> <td>${book.author}</td> <td>${book.price}</td> <td> <a href="${pageContext.request.contextPath }/books?method=delete&id=${book.id }">删除</a><br> <a href="${pageContext.request.contextPath }/books?method=update&id=${book.id }">修改</a> </td> </tr> </c:forEach> </table> <a href="${pageContext.request.contextPath }/bookAdd.jsp" >添加</a> </body> </html> ![]() <%@ page language="java" contentType="text/html; charset=UTF-8" 在WebContent下增加bookAdd.jsp页面pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java. html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www. http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加书籍</title> <script type="text/javascript"> <% %> </script> </head> <body> <form action="${pageContext.request.contextPath }/books?method=add" method="post"> <input type="hidden" name="id" value="${book.id }"> <table> <tr> <td>封面:</td> <td><input name="image" type="text" value="${book.image }"></td> </tr> <tr> <td>书名:</td> <td><input name="name" type="text" value="${book.name }"></td> </tr> <tr> <td>作者:</td> <td><input name="author" type="text" value="${book.author }"></td> </tr> <tr> <td>价格:</td> <td><input name="price" type="text" value="${book.price }"></td> </tr> <tr> <td><button>提交</button></td> </tr> </table> </form> </body> </html> |
只有本站会员才能查看附件,请 登录