在head.jsp中:添加包含h1和div(写上登录部分代码),并删掉path等信息(细节,原因,使用include,导入后,被导入jsp文件中将出现path参数定义冲突)。
其他jsp页面引用, <%@ includefile="/head.jsp"%>
由LoginUserAction(Servlet)中,{登录成功}跳转
// 绑定登录用户到Session(一次浏览器开闭)会话中
request.getSession().setAttribute("loginUser",u);
//由doAllProduct请求跳转。
request.getRequestDispatcher("/doAllProduct").forward(request,response);
head.jsp中,
div中判断Session中有无 ${sessionScope.loginUser} 使用c标签
<c:choose>
<c:when test=” ${ empty sessionScope.loginUser}”>
账号:
</c:when>
<c:otherwise>
欢迎【${sessionScope.loginUser.userName}】进入本商城!<a href="doLoginOut">注销</a>