BBS论坛系统实现-搭建Struts2+Hibernate开发环境

BBS论坛系统实现-搭建Struts2+Hibernate开发环境

1:加载Struts2框架,需要手动配置struts.xml文件。在src中建立struts.xml文件

2:要在项目中使用Struts2框架技术需要在web.xml文件中加载核心控制器FilterDispatcher.

3:hibernate.cfg.xml配置文件。

环境已经搭建好,下面就是写实体类

package entity;



import java.sql.Timestamp;


public class User implements java.io.Serializable {

    private Integer userId;
    private String userName;
    private String userPassword;
    private String userEmail;
    private String userNickname;
    private Timestamp userBirthday;
    private Integer sex;
    private Integer userPoints;
    private String userRemark;

    public User() {
    }

    public User(String userName, String userPassword, String userEmail,
            String userNickname, Timestamp userBirthday, Integer sex,
            Integer userPoints) {
        this.userName = userName;
        this.userPassword = userPassword;
        this.userEmail = userEmail;
        this.userNickname = userNickname;
        this.userBirthday = userBirthday;
        this.sex = sex;
        this.userPoints = userPoints;
    }

    public User(String userName, String userPassword, String userEmail,
            String userNickname, Timestamp userBirthday, Integer sex,
            Integer userPoints, String userRemark) {
        this.userName = userName;
        this.userPassword = userPassword;
        this.userEmail = userEmail;
        this.userNickname = userNickname;
        this.userBirthday = userBirthday;
        this.sex = sex;
        this.userPoints = userPoints;
        this.userRemark = userRemark;
    }

    public Integer getUserId() {
        return this.userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPassword() {
        return this.userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public String getUserEmail() {
        return this.userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getUserNickname() {
        return this.userNickname;
    }

    public void setUserNickname(String userNickname) {
        this.userNickname = userNickname;
    }

    public Timestamp getUserBirthday() {
        return this.userBirthday;
    }

    public void setUserBirthday(Timestamp userBirthday) {
        this.userBirthday = userBirthday;
    }

    public Integer getSex() {
        return this.sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Integer getUserPoints() {
        return this.userPoints;
    }

    public void setUserPoints(Integer userPoints) {
        this.userPoints = userPoints;
    }

    public String getUserRemark() {
        return this.userRemark;
    }

    public void setUserRemark(String userRemark) {
        this.userRemark = userRemark;
    }

}
package entity;

import java.io.Serializable;
import java.sql.Timestamp;

public class Post implements Serializable{

    private Integer postId;//帖子ID
    private User user;//帖子作者
    private String topic;//帖子的标题
    private String matter;//帖子的内容
    private Timestamp postTime;//帖子发表的日期
    public Post(){}
    
    public Post(Integer postId, User user, String topic, String matter,
            Timestamp postTime) {
        super();
        this.postId = postId;
        this.user = user;
        this.topic = topic;
        this.matter = matter;
        this.postTime = postTime;
    }

    public Integer getPostId() {
        return postId;
    }

    public void setPostId(Integer postId) {
        this.postId = postId;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getTopic() {
        return topic;
    }

    public void setTopic(String topic) {
        this.topic = topic;
    }

    public String getMatter() {
        return matter;
    }

    public void setMatter(String matter) {
        this.matter = matter;
    }

    public Timestamp getPostTime() {
        return postTime;
    }

    public void setPostTime(Timestamp postTime) {
        this.postTime = postTime;
    }
    
    
    
    
    
    
    
    
    
    
    
}
package entity;



import java.sql.Timestamp;


public class User implements java.io.Serializable {

    private Integer userId;
    private String userName;
    private String userPassword;
    private String userEmail;
    private String userNickname;
    private Timestamp userBirthday;
    private Integer sex;
    private Integer userPoints;
    private String userRemark;

    public User() {
    }

    public User(String userName, String userPassword, String userEmail,
            String userNickname, Timestamp userBirthday, Integer sex,
            Integer userPoints) {
        this.userName = userName;
        this.userPassword = userPassword;
        this.userEmail = userEmail;
        this.userNickname = userNickname;
        this.userBirthday = userBirthday;
        this.sex = sex;
        this.userPoints = userPoints;
    }

    public User(String userName, String userPassword, String userEmail,
            String userNickname, Timestamp userBirthday, Integer sex,
            Integer userPoints, String userRemark) {
        this.userName = userName;
        this.userPassword = userPassword;
        this.userEmail = userEmail;
        this.userNickname = userNickname;
        this.userBirthday = userBirthday;
        this.sex = sex;
        this.userPoints = userPoints;
        this.userRemark = userRemark;
    }

    public Integer getUserId() {
        return this.userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getUserName() {
        return this.userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getUserPassword() {
        return this.userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public String getUserEmail() {
        return this.userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getUserNickname() {
        return this.userNickname;
    }

    public void setUserNickname(String userNickname) {
        this.userNickname = userNickname;
    }

    public Timestamp getUserBirthday() {
        return this.userBirthday;
    }

    public void setUserBirthday(Timestamp userBirthday) {
        this.userBirthday = userBirthday;
    }

    public Integer getSex() {
        return this.sex;
    }

    public void setSex(Integer sex) {
        this.sex = sex;
    }

    public Integer getUserPoints() {
        return this.userPoints;
    }

    public void setUserPoints(Integer userPoints) {
        this.userPoints = userPoints;
    }

    public String getUserRemark() {
        return this.userRemark;
    }

    public void setUserRemark(String userRemark) {
        this.userRemark = userRemark;
    }

}

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。