2019-01-23 AOP pointCut中获取URL

2019-01-28 16:57:46 浏览数 (2)

代码语言:javascript复制
            RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
            ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes;
            HttpServletRequest httpServletRequest = servletRequestAttributes.getRequest();

            String url = httpServletRequest.getRequestURL().toString();
            String method = httpServletRequest.getMethod();
            String uri = httpServletRequest.getRequestURI();
            String uriSubstring = uri.substring(0, uri.lastIndexOf("/"));
            String queryString = httpServletRequest.getQueryString();
            log.error("请求开始, 各个参数, url: {}, method: {}, uri: {}, params: {}, uriSubstring: {}", url, method, uri,
                    queryString, uriSubstring);

0 人点赞