获取request的两种方式

1、在filter中获取Request

  • HttpServletRequest req = RequestContext.getCurrentContext().getRequest();
  • RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
  • req = ((ServletRequestAttributes) requestAttributes).getRequest();

2、在controller和service中获取Request 

  • RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
  • req = ((ServletRequestAttributes) requestAttributes).getRequest();

获取request的两种方式

上一篇:codeblocks字体设置报错


下一篇:通过qemu模拟器启动内核和文件系统