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()

 

posted @ 2018-01-30 09:47  ^梦幻星空^  阅读(262)  评论(0编辑  收藏  举报