forked from xichangqi/PocketBlogCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiary.jsp
More file actions
169 lines (167 loc) · 4.27 KB
/
Copy pathdiary.jsp
File metadata and controls
169 lines (167 loc) · 4.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" import="java.util.*,com.blog.bean.*,com.blog.dao.*" %>
<%@page import="com.blog.dao.WriteControl"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<LINK href="global.css" type="text/css" rel="stylesheet"/>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DIARY</title>
</head>
<body class="bodyBack">
<%
request.setCharacterEncoding(ConstantUtil.CHAR_ENCODING);
String pages = (String)request.getParameter("pageNo");
int pageNo = 1;
int span = 1;
if(pages != null && pages.length()!=0){
pageNo = Integer.parseInt(pages);
}
User user = (User)session.getAttribute("user");
String uno = (String)request.getAttribute("u_no");
if(uno == null){
uno = request.getParameter("u_no");
}
if(uno == null && user==null){ //用户还未登录
%>
您需要先登录!
<%
}
else {
WriteControl controler = new WriteControl();
controler.getComments("2");
ArrayList<Diary> result = controler.getUserDiary(uno,pageNo,span);
if(result.size() == 0){ //用户还没写微博日志
%>
<h3>没有日志记录</h3>
<%
}
else{
int diarySize = controler.getDiarySize(uno);
for(Diary d:result){
%>
<table width="100%" height="100%" background="img/diary_back.jpg">
<tr>
<td colspan="2" align="left" bgcolor="#339999" class="ziti"><b>日记</b></td>
</tr>
<tr>
<td align="center"><%=d.title %></td>
<font size="2.5"><td align="right">发表于<%=d.time %>
<%
if(user.u_no.equals(uno)){
%>
<a href="WriteServlet?action=toModifyDiary&r_id=<%=d.rid %>&r_title=<%=d.title %>&r_content=<%=d.content %>&u_no=<%=uno %>" >[编辑]</a>
<a href="WriteServlet?action=deleteDiary&r_id=<%=d.rid %>&u_no=<%=uno %>&pageNo=<%=pageNo %>" >[删除]</a>
<%
}
%>
</td></font>
</tr>
<tr>
<td align="left" colspan="2"><%=d.content %></td>
</tr>
</table>
<hr color="#99ccff" size="2"/>
<table bgcolor="#eceff5" width="100%" border="0">
<tr bgcolor="#F0E68C">
<td colspan="2">
<b>评论列表</b>
</td>
</tr>
<%
if(d.commentList.size() == 0){ //暂无评论
%>
<tr><td align="center"/>暂无评论</td></tr>
<%
}
else{
for(Comments c:d.commentList){
%>
<tr>
<td><font size="2.5">
<a href="MyServlet?action=toFriendPage&uno=<%=c.cmtNo %>"><%=c.cmtName %></a>
说:<%=c.content %></font></td>
<td align="right" width="135px"><font size="2.5" >[<%=c.date %>]</font></td>
</tr>
<%
}
}
%>
</table>
<!-- 发表评论模块 -->
<form name="<%=uno %>" action="WriteServlet" method="post">
<table bgcolor="#fff9e2" border="0" width="100%">
<tr>
<td align="left" bgcolor="#99CC66" width="80"><b>发表评论</b></td>
</tr>
<tr>
<td><textarea name="comment" cols="73" rows="3">我来说几句</textarea></td>
</tr>
<tr>
<td align="right">
<input class="btn" type="submit" value="发表评论"/>
<input type="hidden" name="action" value="makeComment"/>
<%
//获得访问者的id
String visitor = user.u_no;
%>
<input type="hidden" name="u_no" value="<%=uno %>" />
<input type="hidden" name="visitor" value="<%=visitor %>" />
<input type="hidden" name="r_id" value="<%=d.rid %>" />
</td>
</tr>
</table>
</form>
<hr/>
<%
}
%>
<table align="center">
<tr>
<%
if(pageNo>1){ //可以上一页
%>
<td align="right">
<a href="diary.jsp?u_no=<%=uno %>&pageNo=<%=(pageNo-1) %>&span=<%=span %>" >
<img src="img/go_back2.png" width="20" height="16" border="0"/>
上一篇
</a>
</td>
<%
}
else{
%>
<td align="right">
<img src="img/go_back2_disable.png" width="20" height="16" />
<u>上一篇</u>
</td>
<%
}
int maxPage = diarySize/span+(diarySize%span==0?0:1);
if(pageNo < maxPage){
%>
<td align="left">
<a href="diary.jsp?u_no=<%=uno %>&pageNo=<%=(pageNo+1) %>&span=<%=span %>">
下一篇
<img src="img/go_forward2.png" width="20" height="16" border="0" />
</a>
</td>
<%
}
else{
%>
<td align="left">
<u>下一篇</u>
<img src="img/go_forward2_disable.png" width="20" height="16" />
</td>
<%
}
%>
</tr>
</table>
<%
}
}
%>
</body>
</html>