两亩三分地

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  17 随笔 :: 20 文章 :: 2 评论 :: 0 Trackbacks
adminCategoryList.jsp 管理Category数据,对其进行修改或删除操作
 1 <%@ page language="java" contentType="text/html; charset=UTF-8"%>
 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 3     "http://www.w3.org/TR/html4/loose.dtd">
 4 <%@page import="com.blog.Category" %>
 5 <%@page import="java.util.List" %>
 6 
 7 <script language="JAVASCRIPT" type="text/javaScript">
 8     function del(){
         var msg =< span style="background-color: #f5f5f5; color: #000000;"& gt; "您真的确定要删除吗?\n\n请确 认!";
10         if (confirm(msg)){
11             return true;
12         }else{
13             return false;
14         }
15     }
16 </script>
17 
18 <html>
19     <head>
 & amp;nbsp;        title>& lt;/span>分类名称管理</title>
21     </head>
22     <body>
 & amp;nbsp;       p< /span>>分类名称管理< span style="color: #0000ff;"></p>
24         <%List categories = (List) request.getAttribute("categories");
25             if(categories != null){%>
26             <table border="1">
27             <tr>
 & amp;nbsp;               td& lt;/span>>< /span>编号< span style="color: #0000ff;"></td>
 & amp;nbsp;               td& lt;/span>>< /span>名称< span style="color: #0000ff;"></td>
 & amp;nbsp;               td& lt;/span>>< /span>操作< span style="color: #0000ff;"></td>
31             </tr>
32             <% for (int i = 0; i < categories.size(); i++) {
33                 Category category = (Category) categories.get(i);
34             %>
35             <tr>
36                 <td><%=category.getId()%></td>
37                 <td><%=category.getName()%></td>
38                 <td>
 & amp;nbsp;                   a& amp;nbsp;href& lt;/span>="/Blog /CategoryServlet?method=edit&id=<%=category.getId()%& gt;">& amp;lt;img& nbsp;src< /span>="/Blog/admin/img /edit.gif"& nbsp;border=0& amp;nbsp;alt< /span>="编辑"& lt;span style="color: #0000ff;">/></a>
 & amp;nbsp;                   a& amp;nbsp;href& lt;/span>="/Blog /CategoryServlet?method=delete&id=<%=category.getId()%& amp;gt;"& nbsp;onclick< span style="color: #0000ff;">><< span style="color: #800000;">img 
< span style="color: #ff0000;">src
< span style="color: #0000ff;">="/Blog/admin/img/delete.gif"< /span> border< /span>=0 < /span>alt< span style="color: #0000ff;">="删除"< span style="color: #0000ff;">/></a>
41                 </td>
42 
43             </tr>
44             <%    }
45             %>
46         </table>
47         <%    }
48         %>
49 
50     </body>
51 </html>
测试http://localhost:8080/Blog/CategoryServlet?method=list

addCategory.jsp Category添加页面,完成添加后转到adminCategroyList页面
 1 <%@ page language="java" contentType="text/html; charset=UTF-8"%>
 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 3     "http://www.w3.org/TR/html4/loose.dtd">
 4 <%@page import="com.blog.Category" %>
 5 
 6 <html>
 7     <head>
  title>& lt;/span>添加博客分类</title>
 9     </head>
10     <body>
 & amp;nbsp;       p< /span>>添加博客分类< span style="color: #0000ff;"></p>
12         <% Category category = (Category) request.getAttribute("category");%>
13         <form id="form1" name="form1" method="post" action="/Blog/CategoryServlet?method=add">
14             <table>
15                 <tr>
 & amp;nbsp;                   td& lt;/span>>< /span>分类名称:< span style="color: #0000ff;"></td>
17                     <td>
18                         <input type="text" name="name" id="name"/>
19                     </td>
20                 </tr>
21                 <tr>
22                     <td colspan="2">
 & amp;nbsp;                        input  type="submit"& lt;/span> name& lt;/span>="submit"< /span> id< /span>="submit" value="提交"< span style="color: #ff0000;"> />
24                     </td>
25                 </tr>
26             </table>
27         </form>
28     </body>
29 </html>
测试http://localhost:8080/Blog/admin/addCategory.jsp 成功!

editCategory.jsp Category编辑页面,更新转至adminCategoryList页面
 1 <%@ page language="java" contentType="text/html; charset=UTF-8"%>
 2 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 3     "http://www.w3.org/TR/html4/loose.dtd">
 4 <%@page import="com.blog.Category" %>
 5 
 6 <html>
 7     <head>
  title>& lt;/span>博客分类修改</title>
 9     </head>
10     <body>
 & amp;nbsp;       p< /span>>输入博客的分类< span style="color: #0000ff;"></p>
12         <% Category category = (Category) request.getAttribute("category");%>
13         <form id="form1" name="form1" method="post" action="/Blog/CategoryServlet?method=update">
14             <input type="hidden" id="id" name="id" value="<%=category.getId()%>"/>
15             <table>
16                 <tr>
 & amp;nbsp;                   td& lt;/span>>< /span>分类名称:< span style="color: #0000ff;"></td>
18                     <td>
19                         <input type="text" name="name" id="name" value="<%=category.getName()%>"/>
20                     </td>
21                 </tr>
22                 <tr>
23                     <td colspan="2">
 & amp;nbsp;                        input  type="submit"& lt;/span> name& lt;/span>="submit"< /span> id< /span>="submit" value="提交"< span style="color: #ff0000;"> />
25                 </tr>
26             </table>
27         </form>
28     </body>
29 </html>
30 
测试成功
posted on 2009-09-28 18:47 Chucky 阅读(102) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航: