`
zwt2001267
  • 浏览: 436003 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

springmvc中获得HttpServletRequest request方法 .

阅读更多

转自:http://blog.csdn.net/wfcaven/article/details/5837181

 

在web。xml中配置一个监听

<listener>
        <listener-class>
            org.springframework.web.context.request.RequestContextListener
        </listener-class>
    </listener>

之后就可以在程序使用了

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

分享到:
评论

相关推荐

    SpringMvc中获取 PathVariable的值的方式.docx

    @RequestMapping(value = "/del/{id}", method = RequestMethod.GET) public void del(HttpServletRequest request, @PathVariable("id") Long id){ System.out.println(id); }

    Logincontroller.java

    public ModelAndView view(HttpServletRequest request){ // String path = request.getParameter("path") + ""; System.out.println("3333"); String path = "pages/index"; ModelAndView mav = new ...

    SpringMvc初步入门简单的例子

    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { request.setAttribute("hello_1", "你好啊, Spring!"); request.setAttribute("hello_...

    springmvc的一个简单实例

    public ModelAndView checkToken(HttpServletRequest request, HttpServletResponse response) { /*ModelAndView view = new ModelAndView("result"); view.addObject("name", request.getParameter("name...

    SpringMVC批量上传

    public String upload(HttpServletRequest request, @RequestParam("designation") String designation, @RequestParam("remark") String remark, //@RequestParam("file") String file, Model model)throws ...

    基于SpringMVC annotation 的图形验证码

    public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // 禁止缓存 response.setHeader("Pragma", "No-cache"); response.setHeader(...

    图片上传并回显插件11111

    springmvc接收传向后台的值方法 @RequestMapping("/admin/addImage.do") public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { Multipart...

    SpringMVC-Mybatis-Shiro-redis-master 权限集成缓存中实例

    HttpServletRequest httpRequest = ((HttpServletRequest)request); /** * 此处是改版后,为了兼容项目不需要部署到root下,也可以正常运行,但是权限没设置目前必须到root 的URI, * 原因:如果你把这个项目叫 ...

    SpringMVC-SSH全注解

    public ModelAndView geUserList2(HttpServletRequest request ,HttpServletResponse response) throws Exception { List&lt;User&gt; lists=userService.getListUsers(); if(lists!=null){ //request....

    SSH_appp.zip

    public String doLogin(@RequestParam String devCode,@RequestParam String devPassword,HttpServletRequest request,HttpSession session){ logger.debug("doLogin===================================="); //...

    SpringMVC框架 |文件下载与文件上传

    文章目录一、SpringMVC支持文件下载二、SpringMVC支持文件上传1.... public ResponseEntity download(HttpServletRequest request) throws Exception { // 1.得到要下载文件的真实路径 ServletContext servletCon

    spring_MVC源码

    弃用了struts,用spring mvc框架做了几个项目,感觉都不错,而且使用了注解方式,可以省掉一大堆配置文件。本文主要介绍使用注解方式配置的spring mvc,之前写的spring3.0 mvc和rest小例子没有介绍到数据层的内容,...

    AisMVC.zip

    public void get(String s1,String s2,HttpServletRequest request, HttpServletResponse response, HttpSession session){ return; } /** * @author gaorui * @return String * 服务端跳转页面处理,默认 ...

    利用SpringMVC过滤器解决vue跨域请求的问题

    之前写过通过注释的方法解决跨域请求的方法...public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { response.setHeader("Access-Control-Allo

    Spring MVC 入门实例

    这篇文章将教你快速地上手使用 Spring 框架....28 public ModelAndView handleRequest(HttpServletRequest request, 29 HttpServletResponse response)throws Exception{ 30 31 request.setAttribute("hello_1",...

    poi导出excel所用jar包,可添加至maven仓库,也可以自己配置,适合各种浏览器

    public String getAll(HttpServletRequest request,HttpServletResponse response) throws IOException{ //集合为需要导出数据,数据查询得到,这里测试就不写了。 List&lt;User&gt; list=new ArrayList(); // 生成...

    一个适合新手学习的电商项目

    public TaotaoResult deleteCartItem(long itemId, HttpServletRequest request, HttpServletResponse response) { // 从cookie中取购物车商品列表 List&lt;CartItem&gt; itemList = getCartItemList(request, ...

    testspringmvcproject.rar

    public ModelAndView view(HttpServletRequest request){ // String path = request.getParameter("path") + ""; String path = "pages/index"; ModelAndView mav = new ModelAndView(); mav.setViewName(path...

    DWR3 访问WEB元素的两种方法实例详解

    第一种是类似于SpringMVC的用法,直接使用,也就是说在需要使用DWR来远程调用的方法上给一个需要用到的WEB元素作为参数,这个参数在调用该方法的时候不需要用户来传递,当调用该方法的时候系统会自动的给该参数赋值...

    微信开发框架wechat4j

    上面代码中的``onText()``是WechatSupport的抽象方法,需要你自己的类来实现,表示对文本消息的处理,示例中是接收到用户的消息之后,返回给用户“test ok”文本消息。 ###创建微信服务地址 创建微信服务地址...

Global site tag (gtag.js) - Google Analytics