📄 book_detail.jsp
字号:
<%@ page contentType="text/html; charset=gb2312" language="java"%>
<%@ page import="java.sql.*"%>
<jsp:useBean scope="page" id="books" class="mypkg.books" />
<jsp:useBean scope="page" id="sorts" class="mypkg.sorts" />
<jsp:useBean scope="page" id="users" class="mypkg.users" />
<jsp:useBean scope="page" id="words" class="mypkg.words" />
<%
//获取用户名
String s_UserName = (String) session.getAttribute("UserName");
if(s_UserName == null)
{
s_UserName = "";
}
//获取所要显示的图书信息
String s_BookID = request.getParameter("BookID");
long l_BookID = 0;
try
{
l_BookID = Long.parseLong(s_BookID);
}
catch(NumberFormatException ex)
{
out.println("<p align=center>非法操作</p>");
out.println("<div align=\"center\"><input type=\"button\" name=\"btn2\" value=\"返回\" onClick=\"javascript:window.history.go(-1)\"></div>");
return;
}
//获取所要修改的图书类别信息
books.setBookID(l_BookID);
if(!books.init())
{
out.println("<p align=center>该图书信息不存在</p>");
out.println("<div align=\"center\"><input type=\"button\" name=\"btn3\" value=\"返回\" onClick=\"javascript:window.history.go(-1)\"></div>");
return;
}
sorts.setSortID(books.getSortID());
sorts.init();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>欢迎光临网上书店</title>
<link rel=stylesheet type=text/css href="../lib/book.css">
</head>
<body bgcolor="#F4FFFE">
<div align="center">
<input type="button" name="btn" value="返回" onClick="javascript:window.history.go(-1)" />
<table width="90%" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="30%" height="20" align="right" rowspan="5"><img src="../picture/<%=books.getPicUrl()%>"></td>
<td width="25%" height="20" align="left"> 【图书名称】 </td>
<td width="45%" height="20" align="left"> <font color="#0000FF"><%=books.getBookName()%></font></td>
</tr>
<tr>
<td width="25%" height="20" align="left"> 【图书类别】 </td>
<td width="45%" height="20" align="left"> <font color="#0000FF"><%=sorts.getSortName()%></font></td>
</tr>
<tr>
<td width="25%" height="20" align="left"> 【作者】 </td>
<td width="45%" height="20" align="left"> <font color="#0000FF"><%=books.getAuthor()%></font></td>
</tr>
<tr>
<td width="25%" height="20" align="left"> 【出版社】 </td>
<td width="45%" height="20" align="left"> <font color="#0000FF"><%=books.getPub()%></font></td>
</tr>
<tr>
<td width="25%" height="20" align="left"> 【价格】 </td>
<td width="45%" height="20" align="left"> <font color="#0000FF"><%=books.getPrice()%></font>(RMB)</td>
</tr>
</table>
<table width="60%" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="100%" align="left" height="40" valign="middle">【图书简介】</td>
</tr>
<tr>
<td width="100%" align="left">
<font color="#0000FF">
<%
//替换图书简介中的回车和换行符号,以便在页面上能正常显示
String s_Intro = books.getIntro();
s_Intro = s_Intro.replaceAll("\r\n","<br>");
out.println(s_Intro);
%>
</font>
</td>
</tr>
<tr>
<td width="100%" align="center" height="40" valign="middle"><input type="button" name="btn1" value="向其他读者推荐该图书" onClick="javascript:window.location='recommend_book.jsp?BookID=<%=books.getBookID()%>'"></td>
</tr>
</table>
<%
//获取当前图书的所有留言信息
words.setBookID(l_BookID);
ResultSet rs = words.show_words();
%>
<table width="60%" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="80%" align="left" height="40" colspan="2" valign="middle">【读者留言】</td>
</tr>
<%
//循环显示当前图书的所有留言信息
while(rs.next())
{
String s_WordContent = rs.getString("WordContent");
s_WordContent = s_WordContent.replaceAll("\r\n","<br>");
long l_AuthorID = rs.getLong("AuthorID");
String s_CreateTime = rs.getString("CreateTime");
users.setUserID(l_AuthorID);
users.init();
%>
<tr bgcolor="#ffffff">
<td width="50%" align="left" height="20">用户:<font color="#0000FF"><%=users.getUserName()%></font></td>
<td width="50%" align="left" height="20">留言时间:<font color="#0000FF"><%=s_CreateTime%></font></td>
</tr>
<tr>
<td width="100%" align="left" colspan="2"><%=s_WordContent%></td>
</tr>
<%
}
%>
</table>
<form name="form1" method="post" action="add_word_save.jsp" target="_self">
<input type="hidden" name="BookID" value="<%=l_BookID%>">
<table width="60%" border="0" cellpadding="0" cellspacing="1">
<tr>
<td width="100%" align="left" height="20"> 用户:<font color="#0000FF"><%=s_UserName%></font></td>
</tr>
<tr>
<td width="100%" align="left" >
<textarea name="WordContent" rows="6" cols="50"></textarea>
</td>
</tr>
<td width="100%" align="left" height="30">
<input type="submit" name="sub" value="发表留言"/>
<input type="button" name="btn" value="返回" onClick="javascript:window.history.go(-1)" />
</td>
</table>
</form>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -