1:RequestContextHolder
通过spring提供的RequestContextHolder在非contrller层获取request
HttpServletRequest request = ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
2:@Autowired
@Autowired
private HttpServletRequest request;