package me.zhengjie.common.utils;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest; /**
* 获取 HttpServletRequest
* @author jie
* @date 2018-11-24
*/
public class RequestHolder { public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
}
}

RequestContextHolder getHttpServletRequest的更多相关文章

  1. 通过RequestContextHolder直接获取HttpServletRequest对象

    问题 朋友遇到一个问题:他想在Service方法中使用HttpServletRequest的API,但是又不想把HttpServletRequest对象当作这个Service方法的参数传过来,原因是这 ...

  2. Spring中RequestContextHolder以及HandlerInterceptorAdapter的使用

    1 . RequestContextHolder 的使用 想要使用RequestContextHolder,要在web.xml中配置RequestContextListener的监听才能使用. //全 ...

  3. 源码分析之RequestContextHolder

    先看源码 /* * Copyright 2002-2012 the original author or authors. * * Licensed under the Apache License, ...

  4. RequestContextHolder 很方便的获取 request

    在 Spring boot web 中我们可以通过 RequestContextHolder 很方便的获取 request. ServletRequestAttributes requestAttri ...

  5. AOP 获取 RequestContextHolder

    转载: http://blog.csdn.net/lexang1/article/details/52619215 在使用spring时,经常需要在普通类中获取session,request等对像. ...

  6. SpringMVC之RequestContextHolder分析

    最近遇到的问题是在service获取request和response,正常来说在service层是没有request的,然而直接从controlller传过来的话解决方法太粗暴,后来发现了Spring ...

  7. 在@Async注解下RequestContextHolder.getRequestAttributes() 获得null的情况

    我们有的时候会在service层获取request填充一些诸如用户名和IP地址等信息,这个时候如果不想从Controller层传request,可以在service直接使用 HttpServletRe ...

  8. RequestContextHolder与RequestContextUtils

    org.springframework.web.servlet.support.RequestContextUtils 在spring-webmvc中, 主要用来获取WebApplicationCon ...

  9. Spring MVC的RequestContextHolder使用误区 good

    JShop简介:jshop是一套使用Java语言开发的B2C网店系统,致力于为个人和中小企业提供免费.好用的网店系统. 项目主页:http://git.oschina.net/dinguangx/js ...

随机推荐

  1. 使用docker-sync解决docker for mac 启动的虚拟容器程序运行缓慢的问题

    背景: 新入职的公司有个非常OG的大项目,为了避免新同学重复造轮子,有哥们已经把项目需要的所有打好了一个镜像供我们启动docker. 初次启动docker 使用的命令如下: docker run -i ...

  2. Java web项目所需技术*(大概)

    实施java 的web项目需要掌握的技术如下: 1.java语言 2.  面向对象分析设计 XML 语言 网页脚本语言 数据库 应用服务器 集成开发环境 .java语言:JSP.Servlet.JDB ...

  3. mnist lenet caffe 测试

    # -*- coding: utf-8 -*-import sysimport numpy as npimport structfrom PIL import Imageprint "hel ...

  4. [Qt5] QSlider设置步长

    这是一个小问题,就是QSlider是一个滑动条控件,既然是个滑动条控件,就会想要用鼠标滚轮或者鼠标去移动它来实现某些功能,但是呢,我能说这个控件的一个属性函数设置也是比较奇怪的,它设置步长的函数有 s ...

  5. 计算机网络(1): http原理和uuid

    http 的请求报文和响应报文格式 请求报文有哪些方法 一个典型的http报文 状态码有哪几种 以及短语是用来解释状态码的 接口测试中,需要使用到UUID,用来生成唯一ID. 1.什么是UUID UU ...

  6. Navicat mysql 数据库备份和使用,备份以后是nb3文件

    通过Navicat进行Mysql数据库自动备份与还原   Mysql数据库自动备份流程 Navicat版本为:Navicat 12.0.26 例:test为用于测试自动备份的数据库,里面有表t_per ...

  7. Bugku杂项(1—28)

    1.签到题 只要关注公众号就可以得到 flag---开胃菜 2.这是一张单纯的图片 用Winhex打开,会发现最下面有一行编码: key{you are right} 是一串HTML编码,解密下就行了 ...

  8. 吴裕雄--天生自然TensorFlow2教程:前向传播(张量)- 实战

    手写数字识别流程 MNIST手写数字集7000*10张图片 60k张图片训练,10k张图片测试 每张图片是28*28,如果是彩色图片是28*28*3-255表示图片的灰度值,0表示纯白,255表示纯黑 ...

  9. ansible-playbook权限提升多种方式

    ansible-playbook 可以方便快速的批量执行部署和运维任务,对于不同的场景和服务器,需要使用不同的权限提升方式. 最佳实现:为了提高playbook的兼容性,跟功能没有直接关系的权限提升脚 ...

  10. python 手动安装模块

    python中 openpyxl是解析 excel 文件的模块,一般使用pip install openpyxl 就可以安装. 但是如果处于公司内网时是无法连网安装的,下面就手动安装进行说明: 1.h ...