@SuppressWarnings("rawtypes") public String bbsLogin() { Map<String, Object> session = context.getSession(); if (log.isDebugEnabled()) { log.debug("bbs登陆方法!"); } String str = "login"; User sessionuser = (User) session.get("user"); if (null == sessionuser) { User userobj = getUser(); Map map = userService.queryUsername(userobj); if (ComonUtil.validateMapResult(map)) { User user1 = (User) map.get(Constant.USER); log.debug("登录成功"); str = "bbs_index"; session.put("user", user1); /** *session共享* */ request.getSession().setAttribute("onlineuser", user1.getUsername()); ServletContext servletContext = request.getSession().getServletContext(); servletContext.setAttribute("session", request.getSession()); /** *** */ onlineUsers.add(user1); } else { log.debug("登陆失败!"); showMessage = "用户名或者密码不正确!"; str = "login"; } } else { str = "bbs_index"; } return str; }
public User getUser() { User userobj = new User(); String username = request.getParameter("username"); String password = CodingCovert.getMD5(request.getParameter("pwd")); userobj.setUsername(username); userobj.setPassword(password); return userobj; }
public BBSMessage getBBSMessage() { String title = request.getParameter("title"); String content = request.getParameter("content"); Map<String, Object> session = context.getSession(); User sessionuser = (User) session.get("user"); BBSMessage bbsMessage = new BBSMessage(); bbsMessage.setTitle(title); bbsMessage.setContent(content); bbsMessage.setUserid(sessionuser.getUserid()); bbsMessage.setCreateTime(new Date()); return bbsMessage; }
public MessageComment getMessageComment() { String messageid = request.getParameter("messageid"); String commentctx = request.getParameter("commentctx"); Map<String, Object> session = context.getSession(); User sessionuser = (User) session.get("user"); MessageComment bbsMessage = new MessageComment(); bbsMessage.setMessageid(Long.parseLong(messageid)); bbsMessage.setCommentctx(commentctx); bbsMessage.setCommenttime(new Date()); if (sessionuser == null) { bbsMessage.setUserid(""); } else { bbsMessage.setUserid(sessionuser.getUserid()); } return bbsMessage; }
/** * bbs用户注册 * * @return */ public String bbsreg() { String str = "login"; Map<String, Object> session = context.getSession(); if (log.isDebugEnabled()) { log.debug("bbs注册方法!"); } User userobj = getUser(); if (userService.queryUserByName(userobj.getUsername())) { userService.addEntity(userobj); session.put("user", userobj); onlineUsers.add(userobj); str = "bbs_index"; } else { showMessage = "用户已存在"; } return str; }