Spring中获取request、response对象的方法

1.直接在方法参数列表里获取

public void myMethod(HttpServletRequest request, HttpServletResponse response){...}

2.在非方法参数列表里获取

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

 

posted @ 2018-04-09 19:28  Jakeylove3  阅读(2780)  评论(0编辑  收藏  举报