1. 程式人生 > >Spring HttpServletRequest對象的獲取

Spring HttpServletRequest對象的獲取

pub http nbsp attr .get method col attribute ext

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對象的獲取