由于是使用spring mvc来做项目,因此脱离了HttpServletRequest作为参数,不能够直接使用request,要想使用request可以使用下面的方法:

在web点xml中配置一个监听

  1. <listener>
  2. <listener-class>
  3. org.springframework.web.context.request.RequestContextListener
  4. </listener-class>
  5. </listener>

之后就可以在程序使用了

  1. HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest()

request.RequestContextListener的更多相关文章

  1. 在springmvc中使用requestContextListener获取全部的request对象

    RequestContextListener实现了 ServletRequestListener ,在其覆盖的requestInitialized(ServletRequestEvent reques ...

  2. 在SpringMVC中获取request对象

    1.注解法 @Autowired private  HttpServletRequest request; 2. 在web.xml中配置一个监听 <listener> <listen ...

  3. spring aop 中获取 request

    使用aop时需要request 和response 使用方法调用时 HttpServletRequest request = ((ServletRequestAttributes)RequestCon ...

  4. RequestContextListener作用

    spring IOC容器实例化Bean的方式有: singleton            在spring IOC容器中仅存在一个Bean实例,Bean以单实例的方式存在. prototype     ...

  5. 在SpringMVC中获取request对象的几种方式

    1.最简单的方式(注解法) @Autowired private HttpServletRequest request; 2.最麻烦的方法 a. 在web.xml中配置一个监听 <listene ...

  6. Spring Mvc 在非controller层 实现获取request对象

    一般我们在Controller层,会编写类似这样的方法 @Controller @RequestMapping(value="/detail") public class GetU ...

  7. 【转载】spring的普通类中如何取session和request对像

    原文地址:http://blog.csdn.net/yousite1/article/details/7108585 首先要在web.xml增加如下代码: <listener> <l ...

  8. springMVC获取request和response

    转载:http://blog.sina.com.cn/s/blog_7085382f0102v9jg.html 1.参数 例如: @RequestMapping("/test") ...

  9. spring IOC容器实例化Bean的方式与RequestContextListener应用

    spring IOC容器实例化Bean的方式有: singleton 在spring IOC容器中仅存在一个Bean实例,Bean以单实例的方式存在. prototype 每次从容器中调用Bean时, ...

随机推荐

  1. 模块划分--MVVM指南(课程学习)

    实现流水化开发,需要使用“模块划分”的程序开发方式.如此,团队里的每个人负责某项\某几项特定的技术领域,在特定的技术领域更加专业.这样,每个人的效率更高.在专业的技能更熟练,更深入,也会提高队员的成就 ...

  2. JavaScript特效制作经典精讲(案例入门详解、可直接粘贴拷贝运行、史上最牛案例)

    技巧一.添加链接提示 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...

  3. JavaScript 扯几句单线程相关

    JavaScript 扯几句单线程相关 众所周知,Javascript是单线程执行的,这也就是说:JavaScript在同一个时间上只能处理一件事.他不像C,Java等这些多 线程的,可以开不同的线程 ...

  4. jquery换肤

    <script src="script/jquery-2.1.0.js"></script>      <link href="style/ ...

  5. VoiceEngine获取硬件信息

    #include "webrtc\voice_engine\include\voe_base.h" #include "webrtc\voice_engine\inclu ...

  6. [MyBatis]mapperLocations属性通配符的使用

    http://blog.csdn.net/szwangdf/article/details/23432783 http://ljhzzyx.blog.163.com/blog/static/38380 ...

  7. 《转》VS2010进行远程调试方法总结

    ---恢复内容开始--- 原文地址:http://blog.sina.com.cn/s/blog_a459dcf5010153o7.html 假设现在有A.B两台PC机. VS2010安装在A机器上, ...

  8. WPF开发进阶 - Fody/PropertyChanged(一)

    INotifyPropertyChanged 在WPF MVVM模式开发中,实现INotifyPropertyChanged的ViewModel是非常重要且常见的类: public class Mai ...

  9. 读书笔记 effective c++ Item 5 了解c++默认生成并调用的函数

    1 编译器会默认生成哪些函数  什么时候空类不再是一个空类?答案是用c++处理的空类.如果你自己不声明,编译器会为你声明它们自己版本的拷贝构造函数,拷贝赋值运算符和析构函数,如果你一个构造函数都没有声 ...

  10. oracle数据库在mybatis中使用uuid

    <insert id="insert" parameterType="com.xxx.SystemDepartment">     <sele ...