Spring HttpServletRequest对象的获取

Posted ^梦幻星空^

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring HttpServletRequest对象的获取相关的知识,希望对你有一定的参考价值。

1、Controller方法上获取

@RequestMapping(value = "/aliyun/ccc/callComing", method = RequestMethod.POST)
public String callComing(HttpServletRequest request) {
}

2、通过注解

@Autowired
HttpServletRequest request;

3、通过代码获取

((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest()

 


以上是关于Spring HttpServletRequest对象的获取的主要内容,如果未能解决你的问题,请参考以下文章