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 ...
随机推荐
- PHP实现app唤起支付宝支付代码
本文主要和大家分享PHP实现app唤起支付宝支付代码,希望能帮助到大家. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...
- 3.4 jmu-java-随机数-使用蒙特卡罗法计算圆周率的值 (10 分)
import java.util.Scanner; import java.util.Random; public class Main { public static void ma ...
- 【模板】Lucas定理
代码如下 #include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn=1e5+10 ...
- [51nod 1830] 路径交
问题描述 给定一棵n个点的树,以及m条路径,每次询问第L条到第R条路径的交集部分的长度(如果一条边同时出现在2条路径上,那么它属于路径的交集). 输入格式 第一行一个数n(n<=500,000) ...
- 算法复习-a 到 z不完全排列生成
在网上看到这个题,觉得很有意思,也算是一种方法...但是复杂度同样很高,生成全排列本身需要很大复杂度. 题目:现在有 a 到 z 26 个元素, 编写程序打印 a 到 z 中任取 3 个元素的组合(比 ...
- 对前端Jenkins自动化部署的研究
1. 安装 安装 Nginx 1.1去官网下直接下载,解压缩 start nginx就可以使了,常用命令: start nginx # 启动 nginx -s reload # 修改配置后重新加载生效 ...
- TypeScript作为前端开发你必须学习的技能(一)
2019年,TypeScript已经开始渐渐的崭露头角,各大框架都说要使用TypeScript,虽然现在还没有完美,但是TypeScript很有可能会成为下一个主流技术. 废话就不多说了,直接开始吧. ...
- 《Spring源码深度解析》二
第二章:容器的基本实现 2.1 基本用法 首先定义一个Bean:(假设在bean包下) 然后定义配置文件: 测试类: 当然,这并非是企业级用法,此处只是用来分析学习其实现 2.2 功能分析 上述三图代 ...
- shell练习--PAT题目1007:关于素数对(失败案例)
让我们定义dn为:dn=pn+1−pn,其中pi是第i个素数.显然有d1=1,且对于n>1有dn是偶数.“素数对猜想”认为“存在无穷多对相邻且差为2的素 ...
- java中System类
System作为系统类,在JDK的java.lang包中,可见它也是一种java的核心语言特性.System类的构造器由private修饰,不允许被实例化.因此,类中的方法也都是static修饰的静态 ...