springmvc 获取不到Response问题

来源:互联网 发布:穿越火线免费刷枪软件 编辑:程序博客网 时间:2024/05/16 09:13

使用如下代码

HttpServletResponse response = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse()

上面方法要想生效,RequestMapping方法必须使用如下格式,也就是参数必须带有HttpServletResponse类型

@RequestMapping("/index")public void index(HttpServletResponse response){}
1 0
原创粉丝点击