Spring中获取request、response对象的方法
1.直接在方法参数列表里获取
public void myMethod(HttpServletRequest request, HttpServletResponse response){...}
2.在非方法参数列表里获取
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
HttpServletResponse response = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getResponse();
文章仅供参考,转载请注明出处。
不怕千万人阻挡,只怕自己投降。