1.直接通过controller层获取到传输到业务层
2.SpringMVC提供的RequestContextHolder可以直接获取
代码:
RequestAttributes requestAttributes = RequestContextHolder.currentRequestAttributes();
// RequestContextHolder.getRequestAttributes();
//从session里面获取对应的值
String str = (String) requestAttributes.getAttribute("name",RequestAttributes.SCOPE_SESSION);

HttpServletRequest request = ((ServletRequestAttributes)requestAttributes).getRequest();
HttpServletResponse response = ((ServletRequestAttributes)requestAttributes).getResponse();

在spring的业务层获取request,response的更多相关文章

  1. spring mvc controller中获取request head内容

    spring mvc controller中获取request head内容: @RequestMapping("/{mlid}/{ptn}/{name}") public Str ...

  2. Spring MVC 中RequestContextHolder获取request和response

    1.最简单方式:处理方法入参 例如: @RequestMapping("/test") @ResponseBody public void saveTest(HttpServlet ...

  3. 怎样在Web项目中的service业务层获取项目根路劲

    这里我们有两个前提 1.没有使用struts2框架.没有使用servlet,无法给service层传递request对象. 2.使用了Spring框架. 那你可能问.会有这样的情况吗?答案是有的,比方 ...

  4. springmvc 获取request response

    RequestContextHolder 获取request public HttpServletRequest getRequest() { return ((ServletRequestAttri ...

  5. spring在service层获取session和request

    首先要在web.xml增加如下代码: <listener> <listener-class>org.springframework.web.context.request.Re ...

  6. 工具类分享之获取Request/Response工具类《RequestContextHolderUtil》

    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/aiyaya_/article/details/78975893前言在开发spring web项目时, ...

  7. SpringMvc4中获取request、response对象的方法

    springMVC4中获取request和response对象有以下两种简单易用的方法: 1.在control层获取 在control层中获取HttpServletRequest和HttpServle ...

  8. java中获取request与response对象的方法

    Java 获取Request,Response对象方法   第一种.参数 @RequestMapping("/test") @ResponseBody public void sa ...

  9. Struts2获取request的几种方式汇总

    Struts2获取request三种方法 struts2里面有三种方法可以获取request,最好使用ServletRequestAware接口通过IOC机制注入Request对象. 在Action中 ...

随机推荐

  1. Educational Codeforces Round 37 G. List Of Integers (二分,容斥定律,数论)

    G. List Of Integers time limit per test 5 seconds memory limit per test 256 megabytes input standard ...

  2. RNN基础

    RNN之所以称为循环神经网路,即一个序列当前的输出与前面的输出也有关.具体的表现形式为网络会对前面的信息进行记忆并应用于当前输出的计算中,即隐藏层之间的节点不再无连接而是有连接的,并且隐藏层的输入不仅 ...

  3. SpiderMan成长记(爬虫之路)

    第一章 爬虫基础 1.1 爬虫基本原理 1.2 请求库 -- urllib库的使用 1.3 请求库 -- requests库的使用 1.4 数据解析 -- 正则基础 1.5 数据解析 -- lxml与 ...

  4. 【线段树 dp】8.6集合

    线段树维护dp 题目大意 给定初始大小为 $N$ 的正整数集合.定义两个数$x$和$y$建立联系的的代价为 $|x-y|$.我们定义整数集合的代价为:将每个整数都与至少一个另外的整数建立联系之后,所有 ...

  5. Orchard Core 使用工作流处理页面提交

    上一篇文章中:Orchard Core 使用工作流处理审批和创建内容项 我们介绍了如何使用工作流处理审批,通过此文章我们了解到工作流的简单使用.但提交数据来自于Postman 本次文章我将演示如何从页 ...

  6. git 解决 error: failed to push some refs to 'https://github.com/xxxx.git'

    在github远程创建仓库后, 利用gitbash进行提交本地文件的时候出现如下错误 [root@foundation38 demo]# git push -u origin master Usern ...

  7. <script language= "javascript " for= "window " event= "onload ">

    狼-志 EVENT   event   设置或获取脚本编写用于的事件   FOR   htmlFor   设置或获取绑定到事件脚本的对象. 可以这样理解. <script   language= ...

  8. 一个列表实现__iter__和__next__方法的例子

    x = ['厉智','陈培昌','程劲','徐晓冬'].__iter__() #这非得这么写不可,否则无法调用下面的__next__()方法,切记! print(x.__next__()) print ...

  9. Vivado与Modelsim联合仿真

    [转载]: 1:https://blog.csdn.net/weixin_37603007/article/details/82823965 2:https://blog.csdn.net/Piece ...

  10. UnhandledExceptionPolicy

    winform程序未捕获异常解决方法  EventType clr20r3 P1 http://blog.csdn.net/chichaodechao/article/details/8294922