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. Tomcat解压版Windows配置(运行环境非开发环境)

    tomcat官网下载的9.0.19,解压后目录如下: java官网下载的jre8 (8u131),目录如下(应该是下载的解压版): 打开tomcat9.0.19根目录下的RUNNING.txt,里面有 ...

  2. 【SpringBoot】SpringBoot Web开发(八)

    本周介绍SpringBoot项目Web开发的项目内容,及常用的CRUD操作,阅读本章前请阅读[SpringBoot]SpringBoot与Thymeleaf模版(六)的相关内容 Web开发 项目搭建 ...

  3. POJ 1062:昂贵的聘礼

    昂贵的聘礼 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 40715   Accepted: 11839 Descripti ...

  4. mongodb与sql语句对比

    左边是mongodb查询语句,右边是sql语句.对照着用,挺方便. db.users.find() select * from users db.users.find({"age" ...

  5. pytorch学习问题汇总

    问题六: 问题五:这里是怎么得到的? 问题四:为什么会是如下结果? torch.bernoulli(a)怎么是这个结果? 问题1:torch各个类型数据格式如何转换?数据类型在官方文档torch.Te ...

  6. 新发布的廉价版iPhoneXR值得购买吗?

    每年苹果九月份的发布会,都是一场声势浩大的全民狂欢"大趴体".其中最兴奋的,自然就是各路段子手--就指望着苹果发布会来提供一年的笑料呢!而今年苹果发布会召开之后,网上最流行的就是下 ...

  7. da道至简读后感

    大道至简,衍化至繁. 往往特别深奥的事却是从特别简洁的发展而成的,就像麦克斯韦仅仅凭一个方程组就统一了电磁学一样,物理学中的算式往往非常简练.开普勒计算天体运行的时候是遵循老师认同的地心说计算的,结果 ...

  8. mysql 启动报错Host name could not be resolved解决办法

    mysql 启动报错信息如下: [root@xxx ~]# 2018-01-26 17:06:35 33 [Warning] Host name 'bogon' could not be resolv ...

  9. JavaWeb开发中遇到问题汇总

    一.基础问题 1.${pageContext.request.contextPath}获取相对路径无效 问题:在jsp中使用${pageContext.request.contextPath}获取相对 ...

  10. 第二季 第四天 part2

    数据类型的转换 转化为字符串 String(value) 转型函数 这个转型函数能把任何类型的值转化为字符串 如果值有toString()方法 则用这个方法(调用没有参数的toString,默认十进制 ...