用spring mvc 做用户的操作日志记录基本有两种方式
1.利用aop做(推荐)
2.利用拦截器做(不推荐)
AOP做操作日志记录基本步骤
1.数据库创建日志表(定义UserOperateLog实体类)
@Entity
@Table(name = "USER_OPERATE_LOG")
public class UserOperateLog implements java.io.Serializable {
/** 版本号 */
private static final long serialVersionUID = 3322584679786620277L;
/** */
private Integer id;
/** 用户id */
private String custId;
/** 用户名 */
private String custName;
/** 真实姓名 */
private String realName;
/** 操作模块 */
private String moduleName;
/** 操作描述 */
private String operateDesc;
/** 操作IP */
private String ipAddress;
/** 操作时间 */
private Date createTime;
/**
* 获取
*
* @return
*/
@Id
@GeneratedValue(generator = "idGenerator")
@GenericGenerator(name = "idGenerator", strategy = "native")
@Column(name = "ID", unique = true, nullable = false, length = 10)
public Integer getId() {
return this.id;
}
/**
* 设置
*
* @param id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取用户id
*
* @return 用户id
*/
@Column(name = "CUST_ID", nullable = true, length = 255)
public String getCustId() {
return this.custId;
}
/**
* 设置用户id
*
* @param custId
* 用户id
*/
public void setCustId(String custId) {
this.custId = custId;
}
/**
* 获取用户名
*
* @re