码迷,mamicode.com
首页 > 其他好文 > 详细

网上图书商城项目学习笔记-009退出功能

时间:2016-01-26 18:21:38      阅读:231      评论:0      收藏:0      [点我收藏+]

标签:

一、退出功能流程分析

技术分享

二、代码

1.view层

1)top.jsp

 1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
 2 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 3 
 4 
 5 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 6 <html>
 7   <head>
 8     <title>top</title>
 9     
10     <meta http-equiv="pragma" content="no-cache">
11     <meta http-equiv="cache-control" content="no-cache">
12     <meta http-equiv="expires" content="0">    
13     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
14     <meta http-equiv="description" content="This is my page">
15     <meta http-equiv="content-type" content="text/html;charset=utf-8">
16     <!--
17     <link rel="stylesheet" type="text/css" href="styles.css">
18     -->
19 <style type="text/css">
20     body {
21         background: #15B69A;
22         margin: 0px;
23         color: #ffffff;
24     }
25     a {
26         text-transform:none;
27         text-decoration:none;
28         color: #ffffff;
29         font-weight: 900;
30     } 
31     a:hover {
32         text-decoration:underline;
33     }
34 </style>
35   </head>
36   
37   <body>
38 <h1 style="text-align: center;">传智播客网上书城系统</h1>
39 <div style="font-size: 10pt; line-height: 10px;">
40 <%-- 根据用户是否登录,显示不同的链接 --%>
41 <c:choose>
42   <c:when test="${empty sessionScope.sessionUser }">
43       <a href="<c:url value=‘/jsps/user/login.jsp‘/>" target="_parent">传智会员登录</a> |&nbsp; 
44       <a href="<c:url value=‘/jsps/user/regist.jsp‘/>" target="_parent">注册传智会员</a>
45   </c:when>
46   <c:otherwise>
47           传智会员:${sessionScope.sessionUser.loginname }&nbsp;&nbsp;|&nbsp;&nbsp;
48       <a href="<c:url value=‘/jsps/cart/list.jsp‘/>" target="body">我的购物车</a>&nbsp;&nbsp;|&nbsp;&nbsp;
49       <a href="<c:url value=‘/jsps/order/list.jsp‘/>" target="body">我的传智订单</a>&nbsp;&nbsp;|&nbsp;&nbsp;
50       <a href="<c:url value=‘/jsps/user/pwd.jsp‘/>" target="body">修改密码</a>&nbsp;&nbsp;|&nbsp;&nbsp;
51       <a href="<c:url value=‘/UserServlet?method=quit‘/>" target="_parent">退出</a>    
52   </c:otherwise>
53 </c:choose>
54 
55 </div>
56   </body>
57 </html>

 

 

2.servlet层

1)UserServlet.java

 

 1     /**
 2      * 退出功能
 3      * @param request
 4      * @param response
 5      * @return
 6      */
 7     public String quit(HttpServletRequest request, HttpServletResponse response) {
 8         request.getSession().invalidate();
 9         return "r:/jsps/user/login.jsp";
10     }

 

网上图书商城项目学习笔记-009退出功能

标签:

原文地址:http://www.cnblogs.com/shamgod/p/5160871.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!