由于sringmvc脱离了HttpServletRequest作为参数,不能够直接使用request,所以得在web.xml里配置RequestContextListener监听访问request:
HttpServletRequst requst = ((ServletRequestAttributes)RequestContextHolder.getRequetAttribute()).getRequest();
本文介绍了在SpringMVC框架中如何通过配置RequestContextListener来间接获取HttpServletRequest对象的方法,这对于那些不再将请求对象直接作为参数传递的情况尤为重要。
由于sringmvc脱离了HttpServletRequest作为参数,不能够直接使用request,所以得在web.xml里配置RequestContextListener监听访问request:
HttpServletRequst requst = ((ServletRequestAttributes)RequestContextHolder.getRequetAttribute()).getRequest();

被折叠的 条评论
为什么被折叠?