0
点赞
收藏
分享

微信扫一扫

Javaweb+mysql校园二手平台(用户设置、发布信息、信息管理、搜索信息,留言,及系统管理)

@TOC

校园二手平台

背景:
本二手交易平台的主要目的是服务于学生,方便学生进行网上交易。其原则是做到界面友好,操作简单且可靠。

功能截图

主要实现的功能点:
系统主要设计了用户设置功能、发布信息功能、信息管理功能、搜索信息功能,留言功能,及系统管理功能模块。

用户注册:学生可利用自已学号进行注册,注册实现实名制。 用户登录:只有登录用户才能进行信息发布。管理员登录后可以进行系统管理。
发布信息:普通用户和管理员登录后都可以发布信息。 修改信息:普通用户可以修改自己发布的信息,管理员可以修改所有信息。
删除信息:普通用户可以删除自己发布的信息,管理员可以删除所有信息。 浏览信息:游客、普通用户和管理员可以浏览所有发布的信息。
搜索信息:游客、普通用户和管理员可以用关键字搜索所有发布的信息。普通用户可以搜索自己发布的所有信息。
发表留言:普通用户和管理员登录后都可以对发布信息进行留言。 查看留言:游客、普通用户和管理员都可以查看发布信息的留言。
删除留言:管理员可以删除留言。 添加二手指南:管理员可以添加二手指南。 查看二手指南:游客、普通用户和管理员都可以查看二手指南。
修改二手指南:管理员可以修改二手指南。 删除二手指南:管理员可以删除二手指南。

主页面:
在这里插入图片描述
搜索页面:
在这里插入图片描述
注册页面:
在这里插入图片描述
二手商品发布:
在这里插入图片描述
二手信息管理:
在这里插入图片描述
留言:
在这里插入图片描述

系统流程图

在这里插入图片描述

技术点介绍

技术:JSP、Struts、Hibernate、Tomcat
JDK:1.7
开发工具:Eclipse(Myeclipse)

源码

1、Dao层:UserDao.java

/*     */ package cn.lee.market.dao;
/*     */ 
/*     */ import cn.lee.market.model.User;
/*     */ import cn.lee.market.struts.actionform.LoginForm;
/*     */ import java.io.PrintStream;
/*     */ import java.util.List;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ import org.hibernate.Criteria;
/*     */ import org.hibernate.LockMode;
/*     */ import org.hibernate.Query;
/*     */ import org.hibernate.Session;
/*     */ import org.hibernate.criterion.Example;
/*     */ 
/*     */ public class UserDAO extends BaseHibernateDAO
/*     */ {
/*  22 */   private static final Log log = LogFactory.getLog(UserDAO.class);
/*     */   public static final String USERNAME = "username";
/*     */   public static final String PASSWORD = "password";
/*     */   public static final String PHOTO = "photo";
/*     */   public static final String QUESTION = "question";
/*     */   public static final String ANSWER = "answer";
/*     */   public static final String EMAIL = "email";
/*     */   public static final String QQ = "qq";
/*     */   public static final String STATUS = "status";
/*     */   public static final String ROLE = "role";
/*     */ 
/*     */   public void save(User transientInstance)
/*     */   {
/*  37 */     log.debug("saving User instance");
/*     */     try {
/*  39 */       getSession().save(transientInstance);
/*  40 */       log.debug("save successful");
/*     */     } catch (RuntimeException re) {
/*  42 */       log.error("save failed", re);
/*  43 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void delete(User persistentInstance) {
/*  48 */     log.debug("deleting User instance");
/*     */     try {
/*  50 */       getSession().delete(persistentInstance);
/*  51 */       log.debug("delete successful");
/*     */     } catch (RuntimeException re) {
/*  53 */       log.error("delete failed", re);
/*  54 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public User findById(String id) {
/*  59 */     log.debug("getting User instance with id: " + id);
/*     */     try {
/*  61 */       return (User)getSession()
/*  62 */         .get(User.class, id);
/*     */     }
/*     */     catch (RuntimeException re) {
/*  65 */       log.error("get failed", re);
/*  66 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public List findByExample(User instance)
/*     */   {
/*  72 */     log.debug("finding User instance by example");
/*     */     try {
/*  74 */       List results = getSession()
/*  75 */         .createCriteria(User.class)
/*  76 */         .add(Example.create(instance))
/*  77 */         .list();
/*  78 */       log.debug("find by example successful, result size: " + results.size());
/*  79 */       return results;
/*     */     } catch (RuntimeException re) {
/*  81 */       log.error("find by example failed", re);
/*  82 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public List findByProperty(String propertyName, Object value) {
/*  87 */     log.debug("finding User instance with property: " + propertyName + 
/*  88 */       ", value: " + value);
/*     */     try {
/*  90 */       String queryString = "from User as model where model." + 
/*  91 */         propertyName + "= ?";
/*  92 */       Query queryObject = getSession().createQuery(queryString);
/*  93 */       queryObject.setParameter(0, value);
/*  94 */       return queryObject.list();
/*     */     } catch (RuntimeException re) {
/*  96 */       log.error("find by property name failed", re);
/*  97 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public List findByUsername(Object username) {
/* 102 */     return findByProperty("username", username);
/*     */   }
/*     */ 
/*     */   public List findByPassword(Object password) {
/* 106 */     return findByProperty("password", password);
/*     */   }
/*     */ 
/*     */   public List findByPhoto(Object photo) {
/* 110 */     return findByProperty("photo", photo);
/*     */   }
/*     */ 
/*     */   public List findByQuestion(Object question) {
/* 114 */     return findByProperty("question", question);
/*     */   }
/*     */ 
/*     */   public List findByAnswer(Object answer) {
/* 118 */     return findByProperty("answer", answer);
/*     */   }
/*     */ 
/*     */   public List findByEmail(Object email) {
/* 122 */     return findByProperty("email", email);
/*     */   }
/*     */ 
/*     */   public List findByQq(Object qq) {
/* 126 */     return findByProperty("qq", qq);
/*     */   }
/*     */ 
/*     */   public List findByStatus(Object status) {
/* 130 */     return findByProperty("status", status);
/*     */   }
/*     */ 
/*     */   public List findByRole(Object role) {
/* 134 */     return findByProperty("role", role);
/*     */   }
/*     */ 
/*     */   public User merge(User detachedInstance) {
/* 138 */     log.debug("merging User instance");
/*     */     try {
/* 140 */       User result = (User)getSession()
/* 141 */         .merge(detachedInstance);
/* 142 */       log.debug("merge successful");
/* 143 */       return result;
/*     */     } catch (RuntimeException re) {
/* 145 */       log.error("merge failed", re);
/* 146 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void attachDirty(User instance) {
/* 151 */     log.debug("attaching dirty User instance");
/*     */     try {
/* 153 */       getSession().saveOrUpdate(instance);
/* 154 */       log.debug("attach successful");
/*     */     } catch (RuntimeException re) {
/* 156 */       log.error("attach failed", re);
/* 157 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void attachClean(User instance) {
/* 162 */     log.debug("attaching clean User instance");
/*     */     try {
/* 164 */       getSession().lock(instance, LockMode.NONE);
/* 165 */       log.debug("attach successful");
/*     */     } catch (RuntimeException re) {
/* 167 */       log.error("attach failed", re);
/* 168 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public User findByUsername(String username) {
/* 173 */     log.debug("getting User instance with username: " + username);
/*     */     try {
/* 175 */       String queryString = "from User where username = '" + username.trim() + "'";
/* 176 */       Query queryObject = getSession().createQuery(queryString);
/* 177 */       List userList = queryObject.list();
/* 178 */       System.out.println(userList);
/* 179 */       if (userList == null || userList.size()==0)
/*     */       {
/* 181 */         System.out.println("没有些用户名!");
/* 182 */         return null;
/*     */       }
/*     */ 
/* 186 */       System.out.println("找到用户:" + ((User)userList.get(0)).getUsername());
/* 187 */       return (User)userList.get(0);
/*     */     }
/*     */     catch (RuntimeException re) {
/* 190 */       log.error("get failed", re);
/* 191 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public List findByStu_id(String stu_id) {
/* 196 */     log.debug("getting User instance with stu_id: " + stu_id);
/*     */     try {
/* 198 */       String queryString = "from User as model where model.MStudent = '" + stu_id + "'";
/* 199 */       Query queryObject = getSession().createQuery(queryString);
/* 200 */       return queryObject.list();
/*     */     } catch (RuntimeException re) {
/* 202 */       log.error("get failed", re);
/* 203 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public User getUser(LoginForm loginForm) {
/* 208 */     log.debug("getting User instance with LoginForm: " + loginForm.getUsername() + ":" + loginForm.getPassword());
/*     */     try {
/* 210 */       String queryString = "from User where username = '" + loginForm.getUsername().trim() + "'" + 
/* 211 */         " and password = '" + loginForm.getPassword() + "'";
/* 212 */       Query queryObject = getSession().createQuery(queryString);
/* 213 */       return (User)queryObject.uniqueResult();
/*     */     }
/*     */     catch (RuntimeException re) {
/* 216 */       log.error("get failed", re);
/* 217 */       throw re;
/*     */     }
/*     */   }
/*     */ }

CommentDao.java

/*     */ package cn.lee.market.dao;
/*     */ 
/*     */ import cn.lee.market.model.Comment;
/*     */ import cn.lee.market.model.Message;
/*     */ import java.util.List;
/*     */ import org.apache.commons.logging.Log;
/*     */ import org.apache.commons.logging.LogFactory;
/*     */ import org.hibernate.Criteria;
/*     */ import org.hibernate.LockMode;
/*     */ import org.hibernate.Query;
/*     */ import org.hibernate.Session;
/*     */ import org.hibernate.criterion.Example;
/*     */ 
/*     */ public class CommentDAO extends BaseHibernateDAO
/*     */ {
/*  22 */   private static final Log log = LogFactory.getLog(CommentDAO.class);
/*     */   public static final String CONTENT = "content";
/*     */ 
/*     */   public void save(Comment transientInstance)
/*     */   {
/*  29 */     log.debug("saving Comment instance");
/*     */     try {
/*  31 */       getSession().save(transientInstance);
/*  32 */       log.debug("save successful");
/*     */     } catch (RuntimeException re) {
/*  34 */       log.error("save failed", re);
/*  35 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void delete(Comment persistentInstance) {
/*  40 */     log.debug("deleting Comment instance");
/*     */     try {
/*  42 */       getSession().delete(persistentInstance);
/*  43 */       log.debug("delete successful");
/*     */     } catch (RuntimeException re) {
/*  45 */       log.error("delete failed", re);
/*  46 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public Comment findById(String id) {
/*  51 */     log.debug("getting Comment instance with id: " + id);
/*     */     try {
/*  53 */       return (Comment)getSession()
/*  54 */         .get(Comment.class, id);
/*     */     }
/*     */     catch (RuntimeException re) {
/*  57 */       log.error("get failed", re);
/*  58 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public List findByExample(Comment instance)
/*     */   {
/*  64 */     log.debug("finding Comment instance by example");
/*     */     try {
/*  66 */       List results = getSession()
/*  67 */         .createCriteria(Comment.class)
/*  68 */         .add(Example.create(instance))
/*  69 */         .list();
/*  70 */       log.debug("find by example successful, result size: " + results.size());
/*  71 */       return results;
/*     */     } catch (RuntimeException re) {
/*  73 */       log.error("find by example failed", re);
/*  74 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public List findByProperty(String propertyName, Object value) {
/*  79 */     log.debug("finding Comment instance with property: " + propertyName + 
/*  80 */       ", value: " + value);
/*     */     try {
/*  82 */       String queryString = "from Comment as model where model." + 
/*  83 */         propertyName + "= ?";
/*  84 */       Query queryObject = getSession().createQuery(queryString);
/*  85 */       queryObject.setParameter(0, value);
/*  86 */       return queryObject.list();
/*     */     } catch (RuntimeException re) {
/*  88 */       log.error("find by property name failed", re);
/*  89 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public List findByContent(Object content) {
/*  94 */     return findByProperty("content", content);
/*     */   }
/*     */ 
/*     */   public Comment merge(Comment detachedInstance) {
/*  98 */     log.debug("merging Comment instance");
/*     */     try {
/* 100 */       Comment result = (Comment)getSession()
/* 101 */         .merge(detachedInstance);
/* 102 */       log.debug("merge successful");
/* 103 */       return result;
/*     */     } catch (RuntimeException re) {
/* 105 */       log.error("merge failed", re);
/* 106 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void attachDirty(Comment instance) {
/* 111 */     log.debug("attaching dirty Comment instance");
/*     */     try {
/* 113 */       getSession().saveOrUpdate(instance);
/* 114 */       log.debug("attach successful");
/*     */     } catch (RuntimeException re) {
/* 116 */       log.error("attach failed", re);
/* 117 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public void attachClean(Comment instance) {
/* 122 */     log.debug("attaching clean Comment instance");
/*     */     try {
/* 124 */       getSession().lock(instance, LockMode.NONE);
/* 125 */       log.debug("attach successful");
/*     */     } catch (RuntimeException re) {
/* 127 */       log.error("attach failed", re);
/* 128 */       throw re;
/*     */     }
/*     */   }
/*     */ 
/*     */   public List findAllCommentOfMessage(Message message) {
/* 133 */     log.debug("finding Comment instance with messageid: " + message.getId());
/*     */     try {
/* 135 */       String queryString = "from Comment as model where model.TMessage= '" + 
/* 136 */         message.getId() + "'";
/* 137 */       Query queryObject = getSession().createQuery(queryString);
/* 138 */       return queryObject.list();
/*     */     } catch (RuntimeException re) {
/* 140 */       log.error("find by messageid  failed", re);
/* 141 */       throw re;
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\muye\Desktop\51\校园二手交易平台设计与论文\market\code\market\WEB-INF\classes\
 * Qualified Name:     cn.lee.market.dao.CommentDAO
 * JD-Core Version:    0.6.1
 */

2、model类:
Comment.java

/*    */ package cn.lee.market.model;
/*    */ 
/*    */ import java.util.Date;
/*    */ 
/*    */ public class Comment extends BaseModel
/*    */ {
/*    */   private User TUser;
/*    */   private Message TMessage;
/*    */   private String content;
/*    */   private Date create_time;
/*    */ 
/*    */   public Comment()
/*    */   {
/*    */   }
/*    */ 
/*    */   public Comment(User TUser, Message TMessage, String content, Date create_time)
/*    */   {
/* 31 */     this.TUser = TUser;
/* 32 */     this.TMessage = TMessage;
/* 33 */     this.content = content;
/* 34 */     this.create_time = create_time;
/*    */   }
/*    */ 
/*    */   public User getTUser()
/*    */   {
/* 41 */     return this.TUser;
/*    */   }
/*    */ 
/*    */   public void setTUser(User TUser) {
/* 45 */     this.TUser = TUser;
/*    */   }
/*    */ 
/*    */   public Message getTMessage() {
/* 49 */     return this.TMessage;
/*    */   }
/*    */ 
/*    */   public void setTMessage(Message TMessage) {
/* 53 */     this.TMessage = TMessage;
/*    */   }
/*    */ 
/*    */   public String getContent() {
/* 57 */     return this.content;
/*    */   }
/*    */ 
/*    */   public void setContent(String content) {
/* 61 */     this.content = content;
/*    */   }
/*    */ 
/*    */   public Date getCreate_time() {
/* 65 */     return this.create_time;
/*    */   }
/*    */ 
/*    */   public void setCreate_time(Date create_time) {
/* 69 */     this.create_time = create_time;
/*    */   }
/*    */ }

User.java

/*     */ package cn.lee.market.model;
/*     */ 
/*     */ import java.util.Date;
/*     */ import java.util.HashSet;
/*     */ import java.util.Set;
/*     */ 
/*     */ public class User extends BaseModel
/*     */ {
/*     */   private Student MStudent;
/*     */   private String username;
/*     */   private String password;
/*     */   private Date birthday;
/*     */   private short photo;
/*     */   private String question;
/*     */   private String answer;
/*     */   private String email;
/*     */   private String qq;
/*     */   private Date create_time;
/*     */   private short status;
/*     */   private short role;
/*  30 */   private Set TMessages = new HashSet(0);
/*  31 */   private Set TComments = new HashSet(0);
/*     */ 
/*     */   public User()
/*     */   {
/*     */   }
/*     */ 
/*     */   public User(Student MStudent, String username, String password, Date birthday, short photo, String question, String answer, Date create_time, short status, short role)
/*     */   {
/*  42 */     this.MStudent = MStudent;
/*  43 */     this.username = username;
/*  44 */     this.password = password;
/*  45 */     this.birthday = birthday;
/*  46 */     this.photo = photo;
/*  47 */     this.question = question;
/*  48 */     this.answer = answer;
/*  49 */     this.create_time = create_time;
/*  50 */     this.status = status;
/*  51 */     this.role = role;
/*     */   }
/*     */ 
/*     */   public User(Student MStudent, String username, String password, Date birthday, short photo, String question, String answer, String email, String qq, Date create_time, short status, short role, Set TMessages, Set TComments)
/*     */   {
/*  56 */     this.MStudent = MStudent;
/*  57 */     this.username = username;
/*  58 */     this.password = password;
/*  59 */     this.birthday = birthday;
/*  60 */     this.photo = photo;
/*  61 */     this.question = question;
/*  62 */     this.answer = answer;
/*  63 */     this.email = email;
/*  64 */     this.qq = qq;
/*  65 */     this.create_time = create_time;
/*  66 */     this.status = status;
/*  67 */     this.role = role;
/*  68 */     this.TMessages = TMessages;
/*  69 */     this.TComments = TComments;
/*     */   }
/*     */   public User(String username2, String password2, String question2, String answer2, int photo2, String email2, Date birthday2) {
/*  72 */     this.username = username2;
/*  73 */     this.password = password2;
/*  74 */     this.birthday = birthday2;
/*  75 */     this.photo = (short)photo2;
/*  76 */     this.question = question2;
/*  77 */     this.answer = answer2;
/*  78 */     this.email = email2;
/*  79 */     this.status = 0;
/*  80 */     this.role = 1;
/*     */   }
/*     */ 
/*     */   public Student getMStudent()
/*     */   {
/*  86 */     return this.MStudent;
/*     */   }
/*     */ 
/*     */   public void setMStudent(Student MStudent) {
/*  90 */     this.MStudent = MStudent;
/*     */   }
/*     */ 
/*     */   public String getUsername() {
/*  94 */     return this.username;
/*     */   }
/*     */ 
/*     */   public void setUsername(String username) {
/*  98 */     this.username = username;
/*     */   }
/*     */ 
/*     */   public String getPassword() {
/* 102 */     return this.password;
/*     */   }
/*     */ 
/*     */   public void setPassword(String password) {
/* 106 */     this.password = password;
/*     */   }
/*     */ 
/*     */   public Date getBirthday() {
/* 110 */     return this.birthday;
/*     */   }
/*     */ 
/*     */   public void setBirthday(Date birthday) {
/* 114 */     this.birthday = birthday;
/*     */   }
/*     */ 
/*     */   public short getPhoto() {
/* 118 */     return this.photo;
/*     */   }
/*     */ 
/*     */   public void setPhoto(short photo) {
/* 122 */     this.photo = photo;
/*     */   }
/*     */ 
/*     */   public String getQuestion() {
/* 126 */     return this.question;
/*     */   }
/*     */ 
/*     */   public void setQuestion(String question) {
/* 130 */     this.question = question;
/*     */   }
/*     */ 
/*     */   public String getAnswer() {
/* 134 */     return this.answer;
/*     */   }
/*     */ 
/*     */   public void setAnswer(String answer) {
/* 138 */     this.answer = answer;
/*     */   }
/*     */ 
/*     */   public String getEmail() {
/* 142 */     return this.email;
/*     */   }
/*     */ 
/*     */   public void setEmail(String email) {
/* 146 */     this.email = email;
/*     */   }
/*     */ 
/*     */   public String getQq() {
/* 150 */     return this.qq;
/*     */   }
/*     */ 
/*     */   public void setQq(String qq) {
/* 154 */     this.qq = qq;
/*     */   }
/*     */ 
/*     */   public Date getCreate_time() {
/* 158 */     return this.create_time;
/*     */   }
/*     */ 
/*     */   public void setCreate_time(Date create_time) {
/* 162 */     this.create_time = create_time;
/*     */   }
/*     */ 
/*     */   public short getStatus() {
/* 166 */     return this.status;
/*     */   }
/*     */ 
/*     */   public void setStatus(short status) {
/* 170 */     this.status = status;
/*     */   }
/*     */ 
/*     */   public short getRole() {
/* 174 */     return this.role;
/*     */   }
/*     */ 
/*     */   public void setRole(short role) {
/* 178 */     this.role = role;
/*     */   }
/*     */ 
/*     */   public Set getTMessages() {
/* 182 */     return this.TMessages;
/*     */   }
/*     */ 
/*     */   public void setTMessages(Set TMessages) {
/* 186 */     this.TMessages = TMessages;
/*     */   }
/*     */ 
/*     */   public Set getTComments() {
/* 190 */     return this.TComments;
/*     */   }
/*     */ 
/*     */   public void setTComments(Set TComments) {
/* 194 */     this.TComments = TComments;
/*     */   }
/*     */ }

3、action类:
AddCommentAction.java

/*    */ package cn.lee.market.struts.action;
/*    */ 
/*    */ import cn.lee.market.dao.CommentDAO;
/*    */ import cn.lee.market.dao.MessageDAO;
/*    */ import cn.lee.market.model.Comment;
/*    */ import cn.lee.market.model.Message;
/*    */ import cn.lee.market.model.User;
/*    */ import java.util.Date;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import javax.servlet.http.HttpSession;
/*    */ import org.apache.struts.action.Action;
/*    */ import org.apache.struts.action.ActionForm;
/*    */ import org.apache.struts.action.ActionForward;
/*    */ import org.apache.struts.action.ActionMapping;
/*    */ 
/*    */ public class AddCommentAction extends Action
/*    */ {
/*    */   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
/*    */     throws Exception
/*    */   {
/* 27 */     String content = request.getParameter("content");
/* 28 */     String messageid = request.getParameter("messageid");
/* 29 */     CommentDAO cDao = new CommentDAO();
/* 30 */     MessageDAO mDao = new MessageDAO();
/* 31 */     Message message = mDao.findById(messageid);
/* 32 */     Comment comment = new Comment();
/* 33 */     comment.setTMessage(message);
/* 34 */     comment.setContent(content);
/* 35 */     comment.setCreate_time(new Date());
/* 36 */     User user = (User)request.getSession().getAttribute("user");
/* 37 */     comment.setTUser(user);
/* 38 */     cDao.save(comment);
/*    */ 
/* 41 */     request.setAttribute("messageid", messageid);
/* 42 */     return mapping.findForward("messageDetail");
/*    */   }
/*    */ }

/* Location:           C:\Users\muye\Desktop\51\校园二手交易平台设计与论文\market\code\market\WEB-INF\classes\
 * Qualified Name:     cn.lee.market.struts.action.AddCommentAction
 * JD-Core Version:    0.6.1
 */

MessageDetail.java

/*    */ package cn.lee.market.struts.action;
/*    */ 
/*    */ import cn.lee.market.dao.CommentDAO;
/*    */ import cn.lee.market.dao.MessageDAO;
/*    */ import cn.lee.market.model.Message;
/*    */ import java.io.PrintStream;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.struts.action.Action;
/*    */ import org.apache.struts.action.ActionForm;
/*    */ import org.apache.struts.action.ActionForward;
/*    */ import org.apache.struts.action.ActionMapping;
/*    */ 
/*    */ public class MessageDetailAction extends Action
/*    */ {
/*    */   public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
/*    */     throws Exception
/*    */   {
/* 22 */     MessageDAO mDao = new MessageDAO();
/* 23 */     Message message = null;
/*    */ 
/* 25 */     String messageid = request.getParameter("messageid");
/*    */ 
/* 27 */     if (messageid == null)
/* 28 */       messageid = (String)request.getAttribute("messageid");
/* 29 */     System.out.println("after post messageid:" + messageid);
/*    */ 
/* 31 */     if (messageid == null) {
/* 32 */       message = (Message)request.getAttribute("message");
/*    */     }
/*    */     else {
/* 35 */       message = mDao.findById(messageid);
/* 36 */       message.setTop_value(Integer.valueOf(message.getTop_value().intValue() + 1));
/*    */     }
/*    */ 
/* 45 */     CommentDAO cDao = new CommentDAO();
/* 46 */     request.setAttribute("message", message);
/* 47 */     request.setAttribute("comments", cDao.findAllCommentOfMessage(message));
/* 48 */     return mapping.findForward("messageDetail");
/*    */   }
/*    */ }

/* Location:           C:\Users\muye\Desktop\51\校园二手交易平台设计与论文\market\code\market\WEB-INF\classes\
 * Qualified Name:     cn.lee.market.struts.action.MessageDetailAction
 * JD-Core Version:    0.6.1
 */

写在最后

如果需要全部源码和详细文档,(仅供学习使用),可加博主交流或者关注gongzhonghao:程序猿矛盾体

举报

相关推荐

0 条评论