在SpringMVC中获取request对象的几种方式
2015-08-31 14:29
417 查看
a. 在web.xml中配置一个监听
<listener> <listener-class> org.springframework.web.context.request.RequestContextListener </listener-class> </listener>
b.之后在程序里可以用
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
3.最直接的方法
赠送一个如何在Struts2中获取request对象
HttpServletRequest request = ServletActionContext.getRequest();
相关文章推荐
- 生产者-消费者模型的Java实现
- Java对字符串进行压缩
- Java中ThreadPoolExecutor的参数理解
- Spring错误:The type org.springframework.dao.DataAccessException cannot be resolved. It is indirectly r
- Spring 教程(二) 体系结构
- Java for循环的几种用法详解
- java操作excel
- POI实战-java开发excel详解(第七章 总结)
- POI实战-java开发excel详解(第六章 附录)
- 菜鸟学习Spring——60s利用JoinPoint(连接点)获取参数的值和方法名称()
- 如何在Eclipse中自动添加注释
- Hello World Spring MVC Hello World
- java数据库操作
- eclipse adt 和 android studio 的区别
- POI实战-java开发excel详解(第四章 常用操作-下拉列表)
- POI实战-java开发excel详解(第四章 常用操作-窗口冻结)
- JavaService创建windows系统服务
- Java中的向下转型与向上转型
- POI实战-java开发excel详解(第四章 常用操作-单元格合并与数据读取)
- POI实战-java开发excel详解(第四章 常用操作-注释)