📄 detail.jsp
字号:
<HTML>
<BODY>
<%@ page import="java.util.*, java.sql.*"
contentType="text/html;charset=GB2312" %>
<jsp:useBean id="pool" scope="application" class="chapter10.ConnPool"/>
<%if (session.getAttribute("Name")==null){
response.sendRedirect("login.html");
}%>
<%@ include file="conn.jsp"%>
<%String type=request.getParameter("type");
if (type==null) type="article";
String id=request.getParameter("id");
String articleid=request.getParameter("articleid");
if (type.equals("article")){
sql="select Users.Name as Author,PostDate,Title,Content from Articles,Users "
+"where Articles.ID="+id+" and Users.ID=Articles.AuthorId";
}else{
sql="select Users.Name as Author,PostDate,Title,Content from ReArticles,Users "
+"where ReArticles.ID="+id+" and Users.ID=ReArticles.AuthorId";
}
ResultSet rs =statement.executeQuery(sql);
rs.next();
String postdate=rs.getString("PostDate");
String author=rs.getString("Author");
String title=rs.getString("Title");
%>
<table border="1" cellspacing="0" cellpadding="0" width=60% align=center>
<tr><td colspan=2 align=center>
<%if (author.equals(session.getAttribute("Name"))){%>
<a href="modify.jsp?type=<%=type%>&id=<%=id%>&articleid=<%=articleid%>&work=modify">修改</a>  
<a href="delete.jsp?type=<%=type%>&id=<%=id%>&articleid=<%=articleid%>">删除</a>  
<%}
if (type.equals("article")){%>
<a href="modify.jsp?type=re&id=<%=id%>&work=write">回复文章</a>  
<a href="list.jsp?type=re&id=<%=id%>">查看回复文章</a>  
<%}%>
<a href="list.jsp?type=<%=type%>&id=<%=articleid%>">返回</a></td></tr>
<tr><td>发表日期:</td><td><%=postdate%><td><tr>
<tr><td>作者:</td><td><%=author%><td><tr>
<tr><td>标题:</td><td><%=title%><td><tr>
<%String temp=rs.getString("Content");
String content="";
for (int i=0;i<temp.length();i++){
if (temp.charAt(i)=='\n'){
content+="<br>";
}else{
content+=temp.charAt(i);
}
}
%>
<tr><td colspan=2><%=content%></td></tr>
</table>
<%@ include file="disconn.jsp"%>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -