前言
为了更好地掌握SSH的用法,使用一个纳税服务系统来练手…..搭建SSH框架环境在上一篇已经详细地说明了。http://blog.csdn.net/hon_3y/article/details/72630031
用户模块需求
拥有增删改查和导入导出到EXCEL的功能:
添加用户:有了这个界面,我们就知道实体表的属性有什么了。
添加配置文件
每个模块都应该有自己的配置文件,这样的话就方便我们管理模块之间的功能,不用把所有的配置都写在总文件中。
因此,我们在user模块创建了一个user包,下面又创建了config包来管理配置文件
JavaBean与映射文件
JavaBean
根据上面需求要添加用户的属性,直接写就行了。
public class User implements Serializable {
private String id;
private String dept;
private String account;
private String name;
private String password;
private String headImg;
private boolean gender;
private String state;
private String mobile;
private String email;
private Date birthday;
private String memo;
public static String USER_STATE_VALID = "1";//有效,
public static String USER_STATE_INVALID = "0";//无效
public User() {
}
public User(String id, String dept, String account, String name, String password, String headImg, boolean gender, String state, String mobile, String email, Date birthday, String memo) {
this.id = id;
this.dept = dept;
this.account = account;
this.name = name;
this.password = password;
this.headImg = headImg;
this.gender = gender;
this.state = state;
this.mobile = mobile;
this.email = email;
this.birthday = birthday;
this.memo = memo;
}
//各种setter和getter
}
User.hbm.xml
映射文件也非常简单,因为没有关联关系字段,直接写属性就行了。
/p>
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
写完映射文件,记得要在Spring的总配置文件中读取映射文件…值得注意的是,用户模块专