guestbook.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:7k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=utf-8"%>
  2. <%@ page import="java.util.*"%>
  3. <%@ page import="cn.js.fan.util.*"%>
  4. <%@ page import="cn.js.fan.db.*"%>
  5. <%@ page import="cn.js.fan.web.*"%>
  6. <%@ page import="cn.js.fan.module.guestbook.*"%>
  7. <%@ page import="com.redmoon.forum.plugin.auction.*"%>
  8. <html>
  9. <head>
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  11. <title>留言簿</title>
  12. <link href="shopskin/default/skin.css" rel="stylesheet" type="text/css">
  13. <style type="text/css">
  14. <!--
  15. .style1 {font-size: 16px}
  16. .style2 {
  17. color: #FFFFFF;
  18. font-weight: bold;
  19. }
  20. .style4 {color: #000000}
  21. -->
  22. </style>
  23. </head>
  24. <body leftmargin="0" topmargin="5">
  25. <jsp:useBean id="msg" scope="page" class="cn.js.fan.module.guestbook.MessageDb"/>
  26. <jsp:useBean id="form" scope="page" class="cn.js.fan.security.Form"/>
  27. <%
  28. String content = ParamUtil.get(request, "content");
  29. String shopCode = ParamUtil.get(request, "shopCode");
  30. if (shopCode.equals("")) {
  31. out.print(SkinUtil.makeErrMsg(request, "编码不能为空!"));
  32. return;
  33. }
  34. AuctionShopDb as = new AuctionShopDb();
  35. as = as.getAuctionShopDb(shopCode);
  36. %>
  37. <table width="550" border="0" align="center" cellpadding="0" cellspacing="0">
  38.   <tr>
  39.     <td width="550" height="52" align="center"><strong><span class="guestbook_title"><a href="shop.jsp?userName=<%=StrUtil.UrlEncode(as.getUserName())%>"><%=as.getShopName()%></a>的留言簿</span></strong></td>
  40.   </tr>
  41.   <tr>
  42.     <td valign="top">
  43. <%
  44. if (!content.equals(""))
  45. {
  46. boolean cansubmit = false;
  47. try {
  48. cansubmit = form.cansubmit(request,"guestbook");//防止重复刷新
  49. }
  50. catch (ErrMsgException e) {
  51. out.println(StrUtil.Alert(e.getMessage()));
  52. }
  53. if (cansubmit) {
  54. String ip = request.getRemoteAddr();
  55. String username = ParamUtil.get(request, "username");
  56. if (username.trim().equals(""))
  57. username = "匿名";
  58. try {
  59. msg.setContent(content);
  60. msg.setUserName(username);
  61. msg.setIp(ip);
  62. msg.setShopCode(shopCode);
  63. msg.create();
  64. }
  65. catch (ErrMsgException e) {
  66. out.println(StrUtil.Alert(e.getMessage()));
  67. }
  68. }
  69. }
  70. int pagesize = 10;
  71. Paginator paginator = new Paginator(request);
  72. String sql = "select id from guestbook where shopCode=" + StrUtil.sqlstr(shopCode) + " order by lydate desc";
  73. int total = msg.getObjectCount(sql);
  74. paginator.init(total, pagesize);
  75. int curpage = paginator.getCurPage();
  76. //设置当前页数和总页数
  77. int totalpages = paginator.getTotalPages();
  78. if (totalpages==0)
  79. {
  80. curpage = 1;
  81. totalpages = 1;
  82. }
  83. Iterator ri = msg.list(sql, (curpage-1)*pagesize, curpage*pagesize-1).iterator();
  84. String querystr = "shopCode=" + StrUtil.UrlEncode(shopCode);
  85. %>
  86. <% if(paginator.getTotal()>0){ %>
  87.                 <table width="91%" border="0" cellspacing="0" cellpadding="0" align="center" class="p9" height="24">
  88.                   <tr>
  89.                     <td width="100%" height="24" valign="bottom"><div align="right">共 <b><%=paginator.getTotal() %></b> 条 每页<b><%=paginator.getPageSize() %></b> 条 <b><%=curpage %>/<%=totalpages %></b>
  90.                           <%
  91.     out.print(paginator.getCurPageBlock("?"+querystr));
  92.   %>
  93.                     </div></td>
  94.                   </tr>
  95.                 </table>
  96.                 <%}%>
  97.                 <table width="98%"  border="0" align="center" cellpadding="0" cellspacing="0">
  98.                   <tr bgcolor="#4A7D00">
  99.                     <td height="4" colspan="2"></td>
  100.                   </tr>
  101.                   <tr>
  102.                     <td width="153" height="24" background="shopskin/default/images/guestbookbar.gif">&nbsp;&nbsp;<span class="text_white_bold">本店最新留言</span></td>
  103.                     <td align="right">&nbsp;&nbsp;</td>
  104.                   </tr>
  105.                 </table>
  106.         <%
  107. while (ri.hasNext()) {
  108.   MessageDb md = (MessageDb)ri.next(); %>
  109.         <table width="98%" border="0" align="center" cellpadding="5" cellspacing="0" class="tableframe">
  110.           <tr>
  111.             <td width="27%" height="22" valign="bottom" class="stable style4">用户:<%=StrUtil.toHtml(md.getUserName())%> </td>
  112.             <td width="73%" height="22" valign="bottom" class="stable style4">留言日期:<%=DateUtil.format(md.getLydate(), "yy-MM-dd HH:mm:ss")%></td>
  113.           </tr>
  114.           <tr valign="top">
  115.             <td height="83" colspan="2" class="stable"><%=StrUtil.toHtml(md.getContent())%><br>
  116.                 <%
  117.   String reply = StrUtil.getNullString(md.getReply());
  118.   if (!reply.equals(""))
  119.   {
  120.   %>
  121.                 <br>
  122.                 <font color="#F09F6F">回复:</font><%=StrUtil.toHtml(reply)%> <br>
  123.              日期:<%=md.getLydate()%>
  124.             <% } %>
  125.             </td>
  126.           </tr>
  127.           <tr valign="top">
  128.             <td height="1" colspan="2" bgcolor="#666666"></td>
  129.           </tr>
  130.         </table>
  131.         <br>
  132.         <%}
  133. %>
  134.         <% if(paginator.getTotal()>0){ %>
  135.         <table width="91%" border="0" cellspacing="0" cellpadding="0" align="center" class="p9" height="24">
  136.           <tr>
  137.             <td width="100%" height="24" valign="bottom"><div align="right">共 <b><%=paginator.getTotal() %></b> 条 每页<b><%=paginator.getPageSize() %></b> 条 <b><%=curpage %>/<%=totalpages %></b>
  138.                     <%
  139.     out.print(paginator.getCurPageBlock("?"+querystr));
  140.   %>
  141.             </div></td>
  142.           </tr>
  143.         </table>
  144. <%}%>
  145.         <br>
  146.         <table width="76%" height="150" border="0" align="center" cellpadding="1" cellspacing="0" class="table_frame_gray">
  147. <form action="?" method="post">
  148.           <tr align="center" bgcolor="#4A7D00">
  149.             <td height="24" colspan="3"><span class="style2">请 您 留 言</span></td>
  150.           </tr>
  151.           <tr>
  152.             <td align="center">用户</td>
  153.             <td width="89%" colspan="2"><input name=username size="15">
  154.                 <input name=shopCode type=hidden value="<%=shopCode%>">
  155.             </td>
  156.           </tr>
  157.           <tr>
  158.             <td width="11%" align="center">留言<br>
  159.       内容</td>
  160.             <td colspan="2"><textarea name="content" cols="45" rows="8"></textarea>
  161.             </td>
  162.           </tr>
  163.           <tr>
  164.             <td colspan="3" align="center"><div align="left"> </div>
  165.                 <input name="submit" type="submit" class="stable" value="发送留言"></td>
  166.           </tr></form>
  167.         </table></td>
  168.   </tr>
  169.   <tr>
  170.     <td height="9">&nbsp;</td>
  171.   </tr>
  172. </table>
  173. </body>
  174. <SCRIPT language=javascript id=clientEventHandlersJS>
  175. <!--
  176. function form1_onsubmit()
  177. {
  178. if (form1.content.value=="")
  179. {
  180. alert("留言内容不能为空!");
  181. return false;
  182. }
  183. }
  184. //-->
  185. </SCRIPT>
  186. </html>