您的位置:首页 > 其它

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

2016-01-26 16:41 337 查看
一、退出功能流程分析



二、代码

1.view层

1)top.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>top</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
body {
background: #15B69A;
margin: 0px;
color: #ffffff;
}
a {
text-transform:none;
text-decoration:none;
color: #ffffff;
font-weight: 900;
}
a:hover {
text-decoration:underline;
}
</style>
</head>

<body>
<h1 style="text-align: center;">传智播客网上书城系统</h1>
<div style="font-size: 10pt; line-height: 10px;">
<%-- 根据用户是否登录,显示不同的链接 --%>
<c:choose>
<c:when test="${empty sessionScope.sessionUser }">
<a href="<c:url value='/jsps/user/login.jsp'/>" target="_parent">传智会员登录</a> | 
<a href="<c:url value='/jsps/user/regist.jsp'/>" target="_parent">注册传智会员</a>
</c:when>
<c:otherwise>
传智会员:${sessionScope.sessionUser.loginname }  |  
<a href="<c:url value='/jsps/cart/list.jsp'/>" target="body">我的购物车</a>  |  
<a href="<c:url value='/jsps/order/list.jsp'/>" target="body">我的传智订单</a>  |  
<a href="<c:url value='/jsps/user/pwd.jsp'/>" target="body">修改密码</a>  |  
<a href="<c:url value='/UserServlet?method=quit'/>" target="_parent">退出</a>
</c:otherwise>
</c:choose>

</div>
</body>
</html>


2.servlet层

1)UserServlet.java

/**
* 退出功能
* @param request
* @param response
* @return
*/
public String quit(HttpServletRequest request, HttpServletResponse response) {
request.getSession().invalidate();
return "r:/jsps/user/login.jsp";
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: