论坛短信息(JSP项目)

if("list".equals(action)){
            String username = request.getSession().getAttribute("loginuser").toString();
            //添加要查询的收件人姓名到elements中
            elements.put("sendto", username);
            List bbsList = bmb.getMessages(elements);
            request.setAttribute("msg", bbsList);
            request.getRequestDispatcher("main.jsp").forward(request, response);
        }else if("read".equals(action)){
            int msgid = Integer.parseInt(request.getParameter("msgid"));
            //添加要查询的姓名到elements中
            elements.put("msgid", msgid);
            List bbsList = bmb.getMessages(elements);
            //将该短信的状态改为已读
            Map newElements = new HashMap();
            newElements.put("state", 1);
            bmb.doInsertOrUpdateMsg("update", newElements, elements);
            request.setAttribute("msg", bbsList);
            request.getRequestDispatcher("readMsg.jsp").forward(request, response);
        }else if("del".equals(action)){
            int msgid = Integer.parseInt(request.getParameter("msgid"));
            elements.put("msgid", msgid);
            int result = bmb.doInsertOrUpdateMsg("delete",null, elements);
            if(result>0){
                request.setAttribute("error", "删除成功!");
            }else{
                request.setAttribute("error", "非法操作,请确认当前用户权限!");
            }
            request.getRequestDispatcher("MsgServlet?action=list").forward(request, response);
        }

连接地址:

https://files.cnblogs.com/files/mymbs/MyMessage.zip

你可能感兴趣的:(JSP)