标签:
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