码迷,mamicode.com
首页 > 其他好文 > 详细

操作日志工具类

时间:2015-05-29 15:35:29      阅读:123      评论:0      收藏:0      [点我收藏+]

标签:

package com.util;

import java.util.Date;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;

import org.springframework.context.ApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import com.renmai.db.dao.OperlogsMapper;
import com.renmai.db.model.Operlogs;




/**
 * 操作日志工具类
 * @author renmai
 *2011-3-6
 */
public class OperLogUtil {

	public static void log(String loginname,String content,HttpServletRequest request){
		try {
			if (content!=null && content.trim().length()>0) {
			    ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
				OperlogsMapper mapper=(OperlogsMapper) context.getBean("operlogsMapper");
				Operlogs log=new Operlogs();
				log.setId(UUID.randomUUID().toString());
				log.setContent(content);
				log.setIp(request.getRemoteAddr());
				log.setLoginname(loginname);
				log.setOpertime(new Date());
				
				//mapper.insert(log);
//				MybatisSessionFactory.getSession().commit();
			}
		} catch (Exception e) {
			try {
//				MybatisSessionFactory.getSession().rollback();
			} catch (Exception e1) {
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
	}
}

  

操作日志工具类

标签:

原文地址:http://www.cnblogs.com/a757956132/p/4538531.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!