Service层获取HttpServletRequest request
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liuyunshengsir/article/details/78183058
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder
                .getRequestAttributes()).getRequest();
        //操作日志基本字段
        OperationLog operationLog=new OperationLog();
        operationLog.setOperationLogId(UUIDUtils.create());
        operationLog.setOperationPeople(request.getSession().getAttribute("userName").toString());
        operationLog.setOperationDate(new Date());
        operationLog.setOperationModule("组织架构管理");
        //操作前
        sysDepartmentDao.selectByPrimaryKey(sysDepartment.getCreateId());
        String beforeContent="部门名称:"+sysDepartment.getDepartmentName()+
                ",部门简介:"+sysDepartment.getDepartmentInfo()+
                ",状态:"+sysDepartment.getIsValid();
        operationLog.setOperationIp(request.getLocalAddr());
        int count = 0;
        count = sysDepartmentDao.updateByPrimaryKeySelective(sysDepartment);
        if(count==1){
            //操作后
            sysDepartmentDao.selectByPrimaryKey(sysDepartment.getCreateId());
            String afterContent="部门名称:"+sysDepartment.getDepartmentName()+
                    ",部门简介:"+sysDepartment.getDepartmentInfo()+
                    ",状态:"+sysDepartment.getIsValid();
            operationLog.setOperationContent("操作前:("+beforeContent+")操作后:("+afterContent+")");
            operationLog.setOperationResult("成功");
            operationLogDao.insertOperationLogInfo(operationLog);
        }else{
            operationLog.setOperationResult("失败");
            operationLogDao.insertOperationLogInfo(operationLog);
        }
        return count;
--------------------- 
作者:liuyunshengsir 
来源:CSDN 
原文:https://blog.csdn.net/liuyunshengsir/article/details/78183058 
版权声明:本文为博主原创文章,转载请附上博文链接!
Service层获取HttpServletRequest request的更多相关文章
- [ionic开源项目教程] - 第4讲 通Service层获取数据列表
		
第4讲:通Service层获取数据列表 上一讲中页面的基本架构已完成,这一讲介绍如何通过service层从服务器请求数据,在通过controller层为载体,显示到视图层. 1.在services.j ...
 - spring在service层获取session和request
		
首先要在web.xml增加如下代码: <listener> <listener-class>org.springframework.web.context.request.Re ...
 - 通过.properties配置文件,在Service层获取值
		
问题:从配置文件获取不到值的原因:1.静态变量:2.没通过Spring加载该实例对象. 1. conf.properties配置文件内容: 2. Spring加载配置文件内容,spring-confi ...
 - SpringMVC 之 Controller、Service层职责
		
Controller层 1.接收httpRequest/requestDTO数据 ,检查接收数据参数与格式. 2.传递参数至Service层并接收返回responseDTO数据. 3.包装respon ...
 - 怎样在Web项目中的service业务层获取项目根路劲
		
这里我们有两个前提 1.没有使用struts2框架.没有使用servlet,无法给service层传递request对象. 2.使用了Spring框架. 那你可能问.会有这样的情况吗?答案是有的,比方 ...
 - 在spring的业务层获取request,response
		
1.直接通过controller层获取到传输到业务层2.SpringMVC提供的RequestContextHolder可以直接获取代码: RequestAttributes requestAttri ...
 - 页面间传递前端请求参数和获取参数:Model model,HttpServletRequest request, ModelMap map参数使用与区别
		
Model model, HttpServletRequest request, ModelMap map声明变量 一.下面的方法是需要将请求发过来的数据(或者说参数)传递到重定向的页面/转发的页面的 ...
 - HttpServletRequest request 获取form参数的两种方式
		
@RequestMapping(value="/pay",method = RequestMethod.POST) public String buildRequest(HttpS ...
 - 非controller层获取response和request对象
		
ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttribute ...
 
随机推荐
- tf.get_variable函数的使用
			
tf.get_variable(name, shape, initializer): name就是变量的名称,shape是变量的维度,initializer是变量初始化的方式,初始化的方式有以下几种 ...
 - 微软推出全新的Windows终端应用程序
			
微软正推出一款名为Windows Terminal的新命令行应用程序.它被设计为访问PowerShell,cmd.exe和Windows子系统Linux(WSL)等环境的中心位置.微软正在为想要调整终 ...
 - The Python Challenge 闯关笔记
			
The Python Challenge : http://www.pythonchallenge.com/ Level 0: 看提示图片中为2**38,计算值为274877906944. Hint: ...
 - python基础练习题4
			
题目:现有一个数据库记录文件(0005.txt)保证了学生课程签到的数据记录('2017-03-13 11:50:09',271,131),('2017-03-14 11:52:19',273,131 ...
 - [bzoj4358]permu:莫队+线段树/回滚莫队
			
这道题是几天前水过去的,现在快没印象了,水一发. 首先我们看到它让求解的是最长的值域 连续段长度,很好. 然后就想到了山海经,但但是我还没有做. 然后又想到了很久以前的一次考试的T3旅馆hotel(我 ...
 - 【react学习一】首先先create-react-app 配置less、sass
			
1.安装初始化 npm create-react-app react-demo 2.安装初始化 npm run eject 3.配置sass / less cnpm i sass-loader nod ...
 - eclipse安装hibernate tools插件
			
第一步:在eclipse菜单中选择Help>Install New Software,弹出安装插件的窗口,如图: 在Work with:后面输入http://download.jboss.org ...
 - phantomjs读取文件转换数组
			
//要读取的文件路径,支持TXT和CSV var openFilepath="lieBiao.txt"; phantom.outputEncoding="GB2312&q ...
 - 使用命令在navicat中创建数据库和用户
			
一.用高权限账号登录,即创建连接 二.选择高权限用户右键,调出命令窗口 三.使用sql语句创建数据库 create database 数据库名 DEFAULT CHARACTER SET gbk CO ...
 - [每日一讲] Python系列:字符串(下)
			
字符串的常见操作 """ DATA STRUCTURE Container: Sequence -- String String is immutable.If stri ...