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

操作日志工具类

时间:2015-06-08 11:17:14      阅读:142      评论:0      收藏:0      [点我收藏+]

标签:

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/4560280.html

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