根据需求,数据库的表有:
用户表:user、商城商品表:shop、购物记录表:record
登录页面:
注册页面
商城商品页面
商品新增页面
3. 实验过程中遇到的问题及解决方案
1.jsp 中注销功能实现
登录 action 中登录成功后添加 session:
ActionContext.getContext().getSession().put("username", username);
ActionContext. getContext().getSession().put( "password", userpassword );
在每个 jsp 显示页面头部添加语句判断:
String path=request.getContextPath();
Object username=session.getAttribute("username");
Object password=session.getAttribute("password");
if(username==null||password==null ){
request.getRequestDispatcher( "/admin_login_first.jsp").forward(request, response);
}
当点击注销时,在注销的 jsp 页面中添加: