spring boot获取当前请求的url

 

ServletRequestAttributes requestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = requestAttributes.getRequest();
String url = "http://" + request.getServerName() + ":" + request.getServerPort();

 

posted @ 2020-11-16 17:31  慕尘  阅读(5994)  评论(0编辑  收藏  举报