1.登录成功设置session
request.getSession().setAttribute("user", user);
2.前台test
<div class="col-md-3" style="padding-top:20px"> ???????????????????<ol class="list-inline"> ???????????????????<c:if test="${empty user }"> ???????????????????????<li><a href="${pageContext.request.contextPath }/user?method=loginUI">登录</a></li> ???????????????????????<li><a href="${pageContext.request.contextPath }/user?method=registUI">注册</a></li> ???????????????????</c:if> ???????????????????<c:if test="${not empty user }"> ???????????????????????${user.name }:你好 ???????????????????????<li><a href="${pageContext.request.contextPath }/order?method=findAllByPage&currPage=1">我的订单</a></li> ???????????????????????<li><a href="${pageContext.request.contextPath }/user?method=logOut">退出</a></li> ???????????????????????????????????????????</c:if> ???????????????????????<li><a href="${pageContext.request.contextPath }/jsp/cart.jsp">购物车</a></li> ???????????????????????????????????????????</ol> ???????????????</div>
jsp登录显示
原文地址:https://www.cnblogs.com/jokerq/p/8993816.html